【发布时间】:2010-11-26 09:26:53
【问题描述】:
使用@OutputCache 指令时,您可以在web.config 中定义缓存配置文件如下:
<system.web>
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="myprofile" duration="30" enabled="true" varyByParam="myfield"/>
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>
但是,在我的应用中,我有一些页面需要使用程序化缓存而不是声明性的,例如:
Response.Cache.SetExpires(DateTime.Now.AddSeconds(5));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetValidUntilExpires(true);
是否可以使用 Response.Cache 并利用 outputCacheProfiles? 例如,
Response.Cache.ApplyCacheProfile("myprofile");
【问题讨论】:
标签: .net asp.net caching outputcache