<%@ OutputCache Duration="30" VaryByParam="none" %>
带参数的<%@ OutputCache Duration="60" VaryByParam="temp"%>
页面有temp这个Get参数的时候,就会把当前页面产生的HTML代码产生一个缓存,不同的temp参数会产生不同的缓存
用户控件缓存和页面缓存大体一样
Substitution WEB控件
Substitution 控件用在配置为需要进行缓存的 ASP.NET 网页上。Substitution 控件允许您在页上创建一些区域,这些区域可以用动态方式进行更新,然后集成到缓存页。
Substitution 控件调用的方法必须符合下面的标准:
-
此方法被定义为静态方法(在 Visual Basic 中为共享方法)。
-
此方法接受 HttpContext 类型的参数。
-
此方法返回 String 类型的值。(MSND)
.aspx
<%@ OutputCache Duration="30" VaryByParam="none" %>
..
..
.. <asp:Substitution ID="Substitution1" runat="server" MethodName="GetDate"/>
..
.aspx.cs












当数据量大的时候,最好通过硬盘缓存一起使用


<%@ OutputCache Duration="30" VaryByParam="none" DiskCacheable="true"%>
web.config里可以配置硬盘缓存大小<system.web>
<caching>
<outputCache><diskCache enabled="true",maxSizePerApp="2(M)"></outputCache>
</caching>
<system.web>
<caching>
<outputCache><diskCache enabled="true",maxSizePerApp="2(M)"></outputCache>
</caching>
<system.web>