新手入门 ASP.NET2.0缓存技术
来源:互联网 发布:optical flares mac版 编辑:程序博客网 时间:2024/05/06 19:10
新手入门 ASP.NET2.0缓存技术
2007-12-13 09:43 来源:博客网
ASP.NET2.0提供如下缓存方式:
Output Caching
Fragment Caching
Data Cache
SQL Cache
Cache Configuration
1. Output Caching:
当一个网页被频繁访问时,我们可以把把整个网页缓存起来提高效率,当用户在此访问时,被格式化好的HTML被直接送到客户端。
<%@ OutputCache Duration="120" VaryByParam="none" %>
2. 参数缓存:
根据用户的请求来生成页面,用户的请求只有有限的几种组合,我们根据参数该表缓存内容。
<%@ OutputCache Duration="120" VaryByParam="state" %>
<%--<a href="Default.aspx?state=CA"></a>--%>
3. 硬盘缓存:
默认情况下Output Cache会缓存到硬盘上,我们可通过修改diskcacheenable的属性设置其是否缓存,还可以通过在web config里配置缓存文件的大小。
4. 页面碎片缓存:
页面上部分内容根据请求动态更新,大部分能容被缓存。(如果多个控件需要缓存,可做成一个用户控件)
<%@OutputCache Duration="120" VaryByControl="ControlID" %>
<center><img src="http://myarticle.enet.com.cn/images/2007/1213/1197510156064.jpg" border="0" alt="新手入门 ASP.NET2.0缓存技术"/></center>
5. Cache Data :
建议打开硬盘缓存,缓存时间设的稍长一点,因为IO的开销
DataSet ds=new DataSet();
ds = Cache["restaurant"];
if (ds == null)
{
ds = resDataSet;
Cache["restaurant"] = ds;
}
6. SQL Dependency
配置数据库服务器的sql缓存,然后在页面引用
<center><img src="http://myarticle.enet.com.cn/images/2007/1213/1197510159540.jpg" border="0" alt="新手入门 ASP.NET2.0缓存技术"/></center>
7. Cache Configuration (减少重复定义)
a .web.config定义
<center><img src="http://myarticle.enet.com.cn/images/2007/1213/1197510164294.jpg" border="0" alt="新手入门 ASP.NET2.0缓存技术"/></center>
b. 页面调用
<%@ OutputCache CacheProfile="CacheFor60Seconds" VaryByParam="name" %>
<table width="90%" border="0" cellpadding="0" cellspacing="0" align="center">
<tr> <td><b>热门推荐</b>:</td>
<td><a href="http://www.enet.com.cn/article/2007/1210/A20071210942740.shtml" target="_blank"><font size=2 color=red>无敌命令 删除不能删除的文件
</font></a></td>
<td><a href="http://www.enet.com.cn/article/2007/1211/A20071211943925.shtml" target="_blank"><font size=2 color=red>不怕被攻击 Windows防黑技巧七招</font></a></td>
</tr></table>
- 新手入门 ASP.NET2.0缓存技术
- Asp.net2.0 页面缓存技术
- ASP.NET2.0 缓存(Cache)技术介绍
- Asp.net2.0 页面缓存技术
- ASP.NET2.0缓存(Cache)技术
- ASP.NET2.0缓存(Cache)技术
- ASP.NET2.0缓存(Cache)技术
- ASP.NET2.0缓存(Cache)技术
- ASP.NET2.0缓存
- 转:::asp.net2.0缓存
- ASP.NET2.0_缓存
- ASP.NET2.0_缓存
- ASP.NET2.0_缓存
- Asp.net2.0中的缓存机制
- ASP.NET2.0数据缓存简介
- asp.net2.0的缓存机制
- 设置ASP.NET2.0页面缓存时间
- ASP.NET2.0数据缓存的使用
- 自学.NET之路-C#编程之基础总结
- 技巧 Html元素的动态添加方法
- Hadoop 手册
- PHP面向对象分析设计的61条军规
- ASP连接数据库错误解决办法新法
- 新手入门 ASP.NET2.0缓存技术
- ASP.NET常用的三十三种实用代码
- 实战开发 C# 索引器学习笔记
- 菜鸟入门 认识C#中的委托和事件
- 编程技巧 Asp.net动态生成html页面
- asp.net编程中实现 MD5 加密
- 编程技巧 asp.net控件本质
- DNN 数据访问策略
- asp.net跳转页面的三种方法比较