zoukankan      html  css  js  c++  java
  • 通过web.config来自定义output caching缓存

    我们服务器有开启缓存功能, 缓存功能可以减少您访问网站时候网站在服务器里面的编译时间, 大大加快您网站的访问速度, 如果您需要对您网站进行频繁更新的话, 您可以考虑暂时将缓存时间减少,或者暂时关闭缓存

    请将下列代码放进web.config文件里面放在您网站的根目录;(注:以下remove extension 和add extension的参数要根据您网站的实际脚本填写,如果网站是php网站, 则用.php替代,如果是asp网站则用.asp替代,如果是asp.net网站,请用.aspx就可以了。)

    1.在web.config里面设置缩小缓存的时间,请在web.config里面用下面的定义

          <system.webServer>
                <caching>
                    <profiles>
                        <remove extension=".aspx" />
                        <add extension=".aspx" policy="CacheForTimePeriod" 

    kernelCachePolicy="DontCache" duration="00:00:01" varyByQueryString="*" />
                    </profiles>
                </caching>
          </system.webServer>

    2. 如果要关闭某个页面的caching功能,请在web.config里面用下面的定义

        <configuration>
             <location path="showStockPrice.asp">
               <system.webServer>       
                 <caching>
                    <profiles>
                        <remove extension=".asp" />
                        <add extension=".asp" policy="DontCache" kernelCachePolicy="DontCache"/>
                    </profiles>
                </caching>
               </system.webServer>
           </location>
        </configuration>

    3. 如果要关闭整个程序的caching功能,请在web.config里面用下面的定义

    <configuration>
               <system.webServer>       
                 <caching>
                    <profiles>
                        <remove extension=".asp" />
                        <add extension=".asp" policy="DontCache" kernelCachePolicy="DontCache"/>
                    </profiles>
                </caching>
               </system.webServer>
        </configuration>

    4. 如果要关闭根目录某个或某几个文件夹的caching功能,请在web.config里面用下面的定义

    <location path="~/folderA,~/folderB">
        <system.webServer>
          <caching>
            <profiles>
              <remove extension=".asp" />
              <add extension=".asp" policy="DontCache" kernelCachePolicy="DontCache"/>
            </profiles>
          </caching>
        </system.webServer>
      </location>
    </configuration>

    您网站更新好之后, 建议您重新开启缓存,有利于加快您网站的访问速度。

    IIS7服务器开启缓存功能有什么利弊?查

  • 相关阅读:
    Solr7使用Oracle数据源导入+中文分词
    自动签发https证书工具 cert manager
    Docker容器服务发现方案
    Registrator中文文档
    C#重试公用类
    sqlserver 2017 docker安装(启动代理)
    【转】如何将MySQL数据目录更改为CentOS 7上的新位置
    solr搜索引擎配置使用mongodb作为数据源
    [转]Docker容器可视化监控中心搭建
    AOP缓存实现
  • 原文地址:https://www.cnblogs.com/namehou/p/10270466.html
Copyright © 2011-2022 走看看