当我在不到2-3分钟的时间内刷新我的网站时,Firebug显示了这些很好的请求:
1. /core.css 304 Not modified
2. /core.js 304 Not modified
3. /background.jpg 304 Not modified
但当我在>3分钟后刷新时,我得到:
1. /core.css 200 OK
2. /core.js 200 OK
3. /background.jpg 304 Not modified
为什么我的CSS和JS文件被再次下载而图像没有被下载?
我使用的是ASP.NET MVC3,而不是[OutputCache]
,在我的/Content
文件夹中(所有css、js和img文件都在子文件夹中),我有这个Web.config:
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00" />
</staticContent>
</system.webServer>
</configuration>
它只设置HTTP头Cache-Control: max-age=86400
。因此,基本上CSS、JS和图像被同等对待,但不知何故CSS和JS不会被缓存更长时间……为什么会这样呢?
发布于 2010-10-18 09:20:45
希望这能有所帮助:http://www.iis.net/ConfigReference/system.webServer/staticContent/clientCache
元素的
<clientCache>
元素指定IIS7和更高版本发送到Web客户端的与缓存相关的HTTP头,它控制Web客户端和代理服务器将如何缓存IIS7和更高版本返回的内容...
发布于 2010-09-05 02:36:33
IIS或Visual Studio web服务器会发生这种情况吗?在开发(使用VS web服务器)时,有一段时间感觉到了这种行为,但当在IIS中发布它时,这种情况就不会再发生了。
https://stackoverflow.com/questions/3644748
复制相似问题