zoukankan      html  css  js  c++  java
  • IIS中User-mode caching引起的Cache-Control不为public的问题

    在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>
  • 相关阅读:
    linux软硬链接
    yum配置文件位置
    What is Docker?
    easy_install下载地址及安装
    python setuptools安装
    django--模板
    django基础PROJECT APP View template
    flask+uswgi+nginx+python3.6的venv发布网站ubuntu14.04
    Mixnode 让操作网络资源和数据库一样简单,不一样的爬虫!
    React Native vs. Cordova.
  • 原文地址:https://www.cnblogs.com/dudu/p/iis_user-mode_caching_cache-control_public.html
Copyright © 2011-2022 走看看