页面缓存 OutputCache


<%@ OutputCache Duration="15" VaryByParam="none" %> 使用页面输出缓存
<%@ OutputCache Duration="3600" VaryByParam="id" %> 使用参数变化输出缓存
<%@ OutputCache Duration="3600" VaryByControl="DropDownList1" %> 基于控件变化的输出缓存
<%@ OutputCache Duration="3600" VaryByHeader="User-Agent" %>基于头变化的输出缓存
<%@ OutputCache Duration="3600" VaryByParam="none" VaryByCustom="browser" %>基于浏览器变化的输出缓存
<%@ OutputCache Duration="3600" VaryByParam="none" Location="Any"%>设置缓存的位置
<%@ OutputCache Duration="3600" VaryByParam="none" %> 创建页面输出缓存的文件依赖 当文件修改时 缓存页面自动失效 并重新在下次页面请求是生成 

     Response.AddFileDependency(MapPath("Movies.xml"));

<%@ OutputCache Duration="3600" VaryByParam="none" %>使用编程的方式设置页面输出缓存过期 

    HttpResponse.RemoveOutputCacheItem(Page.ResolveUrl("~/xxxx.aspx"));

     Response.Redirect("~/xxxx.aspx");

 

<%@ OutputCache Duration="3600"  CacheProfile="CachelHours"  %>创建页面输出缓存配置

<system.web>
   <caching>
      <outputCacheSettings>
         <outputCacheProfiles>
            <add name="CacheHour" duration="3600" varyByParam="none"/>
         </outputCacheProfiles>
      </outputCacheSettings>
   </caching>
 </system.web>

 

posted @ 2013-02-18 16:26  yellowshorts  阅读(216)  评论(0编辑  收藏  举报