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

  • 相关阅读:
    大型站点技术架构PDF阅读笔记(一):
    【大话QT之十三】系统软件自己主动部署实现方案
    VS编译duilib项目时候的错误解决方法整理
    Missing iOS Distribution signing identity for …, 在打包的时候发现证书过期了。
    Django项目国际化
    Codeforces Round #297 (Div. 2) 525D Arthur and Walls(dfs)
    BZOJ 2209: [Jsoi2011]括号序列 [splay 括号]
    NOIP2016DAY1题解
    清北学堂入学测试P4751 H’s problem(h)
    BZOJ 3173: [Tjoi2013]最长上升子序列 [splay DP]
  • 原文地址:https://www.cnblogs.com/namehou/p/10270466.html
Copyright © 2011-2022 走看看