当前位置: 移动技术网 > 网络运营>服务器>Windows > IIS中User-mode caching引起的Cache-Control不为public问题的解决方法

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

2019年05月31日  | 移动技术网网络运营  | 我要评论




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>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网