IIS中User-mode caching引起的Cache-Control不为public问题的解决方法
web.config中对应的配置如下:
<configuration>
<system.webserver>
<caching>
<profiles>
<add extension=".css" policy="cacheuntilchange" kernelcachepolicy="cacheuntilchange" duration="00:00:30" />
<add extension=".js" policy="cacheuntilchange" kernelcachepolicy="cacheuntilchange" duration="00:00:30" />
</profiles>
</caching>
</system.webserver>
</configuration>
浏览器中看到的效果:
解决方法:
1、禁用user-mode caching,只用kernel-mode caching。
2、在web.config中加上cachecontrolcustom="public"
<configuration>
<system.webserver>
<staticcontent>
<clientcache cachecontrolcustom="public" cachecontrolmode="usemaxage" cachecontrolmaxage="300.00:00:00" />
</staticcontent>
<caching>
<profiles>
<add extension=".css" policy="dontcache" kernelcachepolicy="cacheuntilchange" duration="30:00:30" />
<add extension=".js" policy="dontcache" kernelcachepolicy="cacheuntilchange" duration="30:00:30" />
</profiles>
</caching>
</system.webserver>
</configuration>
如对本文有疑问,
点击进行留言回复!!
网友评论