【问题标题】:IIS7 + ASP.NET MVC Client Caching Headers Not WorkingIIS7 + ASP.NET MVC 客户端缓存标头不起作用
【发布时间】:2010-12-06 01:49:00
【问题描述】:

我已经在 IIS7 和 Windows Server 2008 上部署了一个 ASP.NET MVC 应用程序。

我已经阅读了这里和网络上的帖子,但无法让该死的客户端缓存工作。

我正在尝试缓存 /Content 文件夹中的所有内容。到目前为止,我已经在 IIS 管理器中选择了该文件夹,并设置了适当的 HTTP 响应标头(在 Common Headers 下)。我还检查了 /Content 文件夹中的 web.config 文件以及正在设置的值。

/Content 中的所有资源都带有这个(来自 FireBug):

Cache-Control   no-cache, no-store, must-revalidate
Pragma        no-cache
Content-Type    image/png
Expires      -1
Last-Modified   Sun, 11 Oct 2009 19:01:40 GMT
Accept-Ranges   bytes
Etag            "f318d643a54aca1:0"
Server        Microsoft-IIS/7.0
X-Powered-By    ASP.NET
Date            Sun, 11 Oct 2009 20:40:01 GMT
Content-Length  620  

请注意正在请求的此静态图像的 Cache-Control 和 Expires 值。

该网站目前在 Debug 中编译(这会改变),但这肯定不会有什么不同吗?

显然我忽略了一些东西,任何想法都会受到赞赏。

谢谢

【问题讨论】:

    标签: asp.net-mvc caching iis-7


    【解决方案1】:

    如果您无法使用 IIS 管理工具使其正常工作,请尝试 Jeff Atwood 的推荐 this thread:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <staticContent>
          <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
        </staticContent>
      </system.webServer>
    </configuration>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-25
      • 1970-01-01
      • 1970-01-01
      • 2013-02-01
      • 2014-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多