您的位置:首页 > 其它

IIS中User-mode caching引起的Cache-Control不为public问题的解决方法

2013-11-22 16:06 501 查看




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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐