当我在不到2-3分钟内刷新我的网站时,Firebug会显示这些漂亮的请求:
1. /core.css 304 Not modified
2. /core.js 304 Not modified
3. /background.jpg 304 Not modified
但是当我在三分钟后刷新页面时,出现以下情况:
1. /core.css 200 OK
2. /core.js 200 OK
3. /background.jpg 304 Not modified
为什么我的CSS和JS文件会再次下载,而图像不会?
我正在使用ASP.NET MVC 3,我没有使用[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不能缓存更长的时间...为什么会这样呢?
[OutputCache]
? - Maxim Zaslavsky