【发布时间】:2016-10-24 12:27:26
【问题描述】:
我们使用 Windows server 2008 R2 Enterprise 和 IIS7.5.7600.16385, 我在服务器上部署了一个简单的网络(asp.net mvc、c#、.net framework 4.5.1)。 像下面这样的控制器,*.cshtml 只输出一个日期时间:
public class DetailController : Controller
{
[OutputCache(Duration = 300, VaryByParam = "id")]
public ActionResult Index(int id)
{
return View();
}
}
当我第一次请求 url http://localhost:80/Detail/Index?id=3 时,响应是正确的:
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)时,max-age 不正确(然后响应来自服务器缓存):
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)。 在我的生产环境中,不正确的 max-age 会导致点击 url 链接从浏览器的磁盘缓存中读取内容。
有人知道如何解决吗?
【问题讨论】:
-
这似乎是.net framework 4.6.2 (394806) 的错误,我们的服务器.net framework 是4.6.2 而不是4.5.1。我在安装了 .net framework 4.5.1 的服务器上尝试,它运行良好,然后我更新到 4.6.2,现在问题出现了
-
请注意,这个错误也影响了 StackExchange 本身。见Nick Craver's answer here 和his (angry) comment on the bug report。