【问题标题】:IIS7.5 max-age issue(asp.net mvc output cache)IIS7.5 max-age 问题(asp.net mvc 输出缓存)
【发布时间】: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 herehis (angry) comment on the bug report

标签: asp.net-mvc outputcache


【解决方案1】:

这是一个已知问题,并且针对 .NET 4.6.2 与 KB151864 一起存在一个错误。

更多详情请看这里:https://github.com/Microsoft/dotnet/issues/330

这将在 .NET 4.6.3 中修复。我目前不知道 4.6.2 是否会更早提供修复。

目前唯一已知的解决方法是尽可能降级并删除 KB151864。

注意:该错误仅影响缓存响应的 Cache-Control 标头中“max-age”属性的编译。实际的缓存机制和生命周期到期正在发挥作用。

【讨论】:

  • 它已在 4.7 上修复,还没有关于向后移植到 4.6.x 的消息。
  • 看起来他们在 May 2017 Preview of Quality Rollup 中为 4.6.2 修复了它。
  • 上面写着:This release is no longer recommended / available.A bug was found in the May 2017 Preview of Quality Rollup installer that is incompatible with the .NET Framework 4.7 installer. The bug only surfaces when the May 2017 Preview of Quality Rollup (this update) and the .NET Framework 4.7 are installed, in that order.
【解决方案2】:

我刚刚与 Microsoft 支持团队交谈,他们是这样回复我的:

建议的解决方法是将框架从 4.6.2 降级到 4.6.1通过卸载更新KB31511864。

转到控制面板 -> 程序 -> 程序和功能 -> 已安装的更新。 并删除KB3151864,这将解决此问题。

【讨论】:

    猜你喜欢
    • 2012-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-27
    • 2017-07-16
    • 2022-09-30
    • 2011-01-22
    • 2011-02-25
    相关资源
    最近更新 更多