首页 > 其他 > 详细

转载 IIS设置浏览器缓存模式

时间:2018-06-28 10:03:07      阅读:269      评论:0      收藏:0      [点我收藏+]

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

转载  更新时间:2013年11月22日 16:06:34   作者:   技术分享图片 我要评论

 
在IIS的Output caching中如果启用了User-mode caching将引起Cache-Control为no-cache,从而造成页面不能被浏览器或代理服务器缓存,下面看解决方法
 

技术分享图片


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>

转载 IIS设置浏览器缓存模式

原文:https://www.cnblogs.com/jlove/p/9237041.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!