我在包含usercontrol的页面上使用Asp.net OutputCache,在某些情况下当编辑usercontrol时,我希望能够过期页面缓存并用新数据重新加载页面。Asp.Net OutputCache和Expiration
有没有什么办法可以在usercontrol内做到这一点?
如果不是,缓存页面的其他方法是什么,这将允许我以这种方式进行编辑。
----------- -----------编辑
一些调查研究后,我发现,似乎运作良好的方法。
Dim cachekey As String = String.Format("Calendar-{0}", calendarID)
HttpContext.Current.Cache.Insert(cachekey, DateTime.Now, Nothing, System.DateTime.MaxValue, System.TimeSpan.Zero, System.Web.Caching.CacheItemPriority.NotRemovable, Nothing)
Response.AddCacheItemDependency(cachekey)
,将添加一个依赖于页面缓存对象,则到期我这样做:
Dim cachekey as string = String.Format("Calendar-{0}", CalendarID)
HttpContext.Current.Cache.Insert(cachekey, DateTime.Now, Nothing, System.DateTime.MaxValue, System.TimeSpan.Zero, System.Web.Caching.CacheItemPriority.NotRemovable, Nothing)
现在只要依赖cachekey是已知的页面可能到期。
是的,这似乎是唯一的例子,但它没有考虑到VaryByParams,所以如果我过期那页,我认为仍然会有缓存中的数据在同一页面上使用不同的查询字符串。 – 2009-01-26 23:42:05