当前位置:编程学习 > C#/ASP.NET >>

asp.net 页面输出缓存

答案:主要用于不经常更新和修改,而在第一次编译是时要经过大量处理的数据。页面输出缓存是缓存的整个页面
使用很简单<%@ OutPutCache Duration="60" VaryByParam="none"%>
Duration:缓存时间
VaryByParam:通过参数来更新缓存的内容
还有其他的一些属性
CacheProfile:调用WebConfig中的缓存时间
例如:WebCofig中
复制代码 代码如下:

<system.web>
<outputCacheSetting>
<outputCacheProfiles>
<add name="cacheTest" duration="50"/>
<outputCacheProfiles>
</outputCahceSetting>
</system.web>

在页面中声明
<%@ OutputCache CacheProfile="cacheTest" VaryByParam="none"%>
VaryByControl:通过控件来改变缓存
<%@OutputCache Duration="60" VaryByParam="none" VaryByControl="Button1"%>

上一个:asp.net 模拟提交有文件上传的表单(通过http模拟上传文件)
下一个:ASP.NET中内嵌页面代码的一个问题

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,