我在包含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