【问题标题】:MVC Client Cache for Static content is not working静态内容的 MVC 客户端缓存不起作用
【发布时间】:2014-09-11 00:02:12
【问题描述】:

我在 web.config 中添加了以下一项

<staticContent>
   <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="10.00:00:00" />
</staticContent>

但我没有看到响应标头过期。我应该做任何其他更改吗?

【问题讨论】:

  • 当我在本地测试时,它没有显示。它在部署到测试服务器后显示。

标签: asp.net-mvc clientcache


【解决方案1】:

我会尝试两件事来调试。首先,我将 cacheControlCustom 从 private 更改为 public

<location path="Content">
  <system.webServer>
    <staticContent>
      <clientCache 
             cacheControlCustom="public" 
             cacheControlMode="UseMaxAge" 
             cacheControlMaxAge="10.00:00:00" />
    </staticContent>
  </system.webServer>
</location>

如果这不起作用,请检查缓存所覆盖路径的位置。您的示例未显示该部分。

最后,尝试通过以下方式解锁机器配置的 StaticContent 部分:

appcmd unlock config /section:staticContent

这是一个链接,其中包含一些额外的有用信息Client Cache

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-02
    • 2012-03-30
    • 2010-12-06
    • 1970-01-01
    • 1970-01-01
    • 2019-01-08
    • 2015-08-07
    • 2015-10-04
    相关资源
    最近更新 更多