IIS7 + ASP.NET MVC 客户端缓存标头不起作用 [英] IIS7 + ASP.NET MVC Client Caching Headers Not Working

查看:28
本文介绍了IIS7 + ASP.NET MVC 客户端缓存标头不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've deployed an ASP.NET MVC app on IIS7 and Windows Server 2008.

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

I've read posts on here, and around the web, but can't get the darn client-side caching to work.

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

I'm trying to cache everything in the /Content folder. So far I've select that folder in IIS manager, and set the appropriate HTTP Response Headers (under Common Headers). I've also checked the web.config file in the /Content folder and the values there are being set.

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

All resources in /Content come back with this (from 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 值.

Note the Cache-Control and Expires values for this static image being requested.

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

The site is currently compiled in Debug (this will change), but surely that wouldn't make a difference?

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

Obviously I'm overlooking something, any ideas would be appreciated.

谢谢

推荐答案

如果您无法使用 IIS 管理工具使其正常工作,请尝试 Jeff Atwood 的建议这个帖子:

If you can't get it working using the IIS admin tool, try Jeff Atwood's recommendation from 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>

这篇关于IIS7 + ASP.NET MVC 客户端缓存标头不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆