一、web.config 配置页面输出缓存
<system.web>
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="pageCache" duration="60" varyByParam="none" enabled ="true"/>
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>
页面调用:
<%@ OutputCache CacheProfile="pageCache" %>
(1)Duration属性
该属性指定页或用户控件进行缓存的时间,以秒为单位。在页或用户控件上设置该属性为来自对象的 HTTP 响应建立了一个过期策略,并将自动缓存页或用户控件输出。
例如:设置页或用户控件进行输出缓存的持续时间为100秒。代码如下:
<%@ OutputCache Duration="100" VaryByParam="none" %>
注意:这是必选属性。如果未包含该属性,将出现分析器错误。