Chinaunix首页 | 论坛 | 博客
  • 博客访问: 131879
  • 博文数量: 16
  • 博客积分: 2500
  • 博客等级: 少校
  • 技术积分: 520
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-18 09:30
文章分类

全部博文(16)

文章存档

2011年(1)

2009年(9)

2008年(6)

我的朋友

分类: 系统运维

2008-09-24 10:55:22

普通的使用方法(页面缓存)
 

<%@ OutputCache Duration="15" VaryByParam="none" %><!--设置单个页面缓存,缓存时间为15秒-->
<%@ OutputCache CacheProfile="AppCache1" VaryByParam="none" %>
<!--设置缓存,利用web.config,里面的AppCache1
     <caching>
        <outputCacheSettings>
          <outputCacheProfiles>
            <add name="AppCache1" enabled="true" duration="60"/>
          </outputCacheProfiles>
        </outputCacheSettings>
      </caching>
 -->
 <%--<%@ OutputCache Location="Server" Duration="60" VaryByParam="Color" %>--%>

使用程序进行缓存(页面缓存)

 

Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
        Response.Cache.SetCacheability(HttpCacheability.Public);
        Response.Cache.SetValidUntilExpires(true)

 
程序缓存
 

Cache.Insert("key", myXMLFileData, new

  System.Web.Caching.CacheDependency(Server.MapPath("users.xml")));  

  该示例可将文件中的 xml 数据插入缓存,无需在以后请求时从文件读取。 CacheDependency 的作用是确保缓存在文件更改后立即到期,以便可以从文件中提取最新数据,重新进行缓存。如果缓存的数据来自若干个文件,还可以指定一个文件名的数组。  

阅读(753) | 评论(0) | 转发(0) |
0

上一篇:asp+水印

下一篇:format的参数

给主人留下些什么吧!~~