在IIS7上的CSS文件上设置缓存不起作用

时间:2014-07-28 15:06:52

标签: iis-7 cache-control

我正在尝试实施Google的Pagespeed关于浏览器缓存的建议(在静态内容上设置Expirer或Cache-control标头)。 在这里阅读了很多帖子(比如IIS7 Cache-Control)和其他网站后,我似乎无法弄清楚为什么Pagespeed仍然拒绝我的CSS文件。

例如:http://test.grotefeesten.nl/clientdata/71/js/jssor.config.js。根据本地PageSpeed,此文件的到期时间为1天,但不符合在线PageSpeed测试。

我的web.config:

 <caching>
  <profiles>
    <add extension=".css" policy="CacheUntilChange" 
     kernelCachePolicy="CacheUntilChange" location="Any" />
  </profiles>
 </caching>
 <httpProtocol>
 <customHeaders>
   <add name="Cache-Control" value="public" />
 </customHeaders>
 </httpProtocol>
 <staticContent>
   <clientCache cacheControlMode="UseMaxAge" cacheControlCustom="max-age"
    cacheControlMaxAge="1.00:00:00" />
 </staticContent>

有人看到我在这里缺少什么来正确设置Expires标头吗?

1 个答案:

答案 0 :(得分:0)

我一直在努力解决这个问题。但是,我找到了一个解决方案:

<httpProtocol>
    <customHeaders>
        <add name="Cache-Control" value="max-age=2592000" />
    </customHeaders>
</httpProtocol>

这就是全部。上面代码"max-age=2592000"中的值是1个月。