IIS7.5最大使用期限问题(asp.net mvc输出缓存) [英] IIS7.5 max-age issue(asp.net mvc output cache)
问题描述
我们使用Windows Server 2008 R2 Enterprise和IIS7.5.7600.16385, 我在服务器上部署了一个简单的网站(asp.net mvc,c#、. net框架4.5.1). 如下所示的控制器,而* .cshtml仅输出日期时间:
We use Windows server 2008 R2 Enterprise And IIS7.5.7600.16385, and i deployed a simple web (asp.net mvc, c#, .net framework 4.5.1) on the server. a controller like below, and *.cshtml only output a datetime:
public class DetailController : Controller
{
[OutputCache(Duration = 300, VaryByParam = "id")]
public ActionResult Index(int id)
{
return View();
}
}
当我第一次请求url http://localhost:80/Detail/Index?id = 3 ,响应是正确的:
when i first request the url http://localhost:80/Detail/Index?id=3 , the response is correct:
Cache-Control:public, max-age=300
Date:Mon, 24 Oct 2016 12:11:59 GMT
Expires:Mon, 24 Oct 2016 12:16:51 GMT
Last-Modified:Mon, 24 Oct 2016 12:11:51 GMT
但是,当我再次请求url(ctrl + f5)时,最大使用时间不正确(然后响应来自服务器缓存):
but, when i request the url again(ctrl+f5), the max-age incorrect (then the response is from the server cache):
Cache-Control:public, max-age=63612908450
Date:Mon, 24 Oct 2016 12:16:34 GMT
Expires:Mon, 24 Oct 2016 12:20:50 GMT
Last-Modified:Mon, 24 Oct 2016 12:15:50 GMT
我不知道为什么max-age这么大以及它是如何生成的,当输出缓存过期时(ctrl + f5)它会重新转换. 在我的生产环境中,错误的最大使用期限导致URL链接单击并从浏览器的磁盘缓存中读取内容.
i don't know why the max-age so large, and how it generated, it will reconvert when the output cache expired (ctrl+f5). In my production env, the incorrect max-age cause a url link click read the content from browser's disk cache.
有人知道如何修复它吗?
any one know how and how to fixed it?
推荐答案
这是一个已知问题,KB151864随附的.NET 4.6.2已打开一个错误.
This is a known issue and a bug is open for .NET 4.6.2 coming with KB151864.
有关其他详细信息,请参见此处: https://github.com/Microsoft/dotnet/issues/330
Please see here for additional details: https://github.com/Microsoft/dotnet/issues/330
这将在.NET 4.6.3中修复.我目前不知道是否会在4.6.2之前提供修复程序.
This is going to be fixed in .NET 4.6.3. I currently don't know if a fix will be made available earlier for 4.6.2.
目前唯一已知的解决方法是在可能的情况下降级并删除KB151864.
The only known workaround at present is to downgrade and remove KB151864, when possible.
注意:该错误仅影响缓存响应的Cache-Control标头中"max-age"属性的编译.实际的缓存机制和生命周期有效.
NOTE: the bug is affecting ONLY the compilation of the "max-age" attribute in the Cache-Control header for the cached responses. The actual caching mechanism and lifetime expiration is working.
这篇关于IIS7.5最大使用期限问题(asp.net mvc输出缓存)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!