4

我有这个代码:

 context.HttpContext.Response.Cache.SetCacheability(HttpCacheability.Public);
 context.HttpContext.Response.Cache.SetMaxAge(TimeSpan.FromHours(24));

回应是这样的:

Status Code: 200
Date: Fri, 14 Dec 2012 13:56:41 GMT
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Content-Length: 38436
X-AspNetMvc-Version: 4.0
Server: Microsoft-IIS/8.0
Content-Type: application/rss+xml; charset=utf-8
Cache-Control: public
X-SourceFiles: =?UTF-8?B?QzpcUHJvamVjdHNcVGVzdFxtYW5nb21pbnQucHVibGljXHNyY1xNYW5nb21pbnQuUHVibGljLldlYlxibG9nXHJzcw==?=

为什么 Cache-Control 上没有定义 max-age?

4

1 回答 1

10

我遇到了同样的问题,这让我发疯了。解决方案是先添加这一行:

context.HttpContext.Response.Cache.SetSlidingExpiration(true);
于 2013-04-25T20:08:31.487 回答