• 通过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服务器开启缓存功能有什么利弊?查

  • 相关阅读:
    笔记:Jersey REST API 设计
    笔记:MyBatis 日志显示-log4j2
    笔记:MyBatis 其他特性
    笔记:MyBatis 动态SQL
    笔记:MyBatis 使用 Java API配置
    【JAVA】辨析:replace,replaceAll,replaceFirst
    【学习总结】计算机网络-纠错编码之海明码or汉明码
    【学习总结】计算机网络-检错编码之奇偶校验码and循环冗余码CRC
    【学习总结】快速上手Linux玩转典型应用-第7章-WebServer安装和配置讲解
    【问题解决方案】visudo: /etc/sudoers is busy, try again later
  • 原文地址:https://www.cnblogs.com/namehou/p/10270466.html
Copyright © 2020-2023  润新知