CacheDependency on all EPiServer PageData?

Vote:
 
I'd like to invalidate some chached objects in the EPiServer Cache class (aka the global ASP.NET Cache class?) whenever any PageData is changed. Any ideas? Does EPiServer keep any Cache objects that updates on these kinds of changes, that I could use as key for CacheDependency?
#12442
Mar 25, 2008 18:34
Vote:
 
Yepp, you can, and you should, and you should have a price for thinking about it :-) This will do the trick: // Make the cache object dependent on the EPiServer // cache, so it will be removed when new pages are // published, deleted or we are notified by // another server that the cache needs refreshing String[] pageCacheDependencyKey = new String[1]; pageCacheDependencyKey[0] = DataFactoryCache.VersionKey; CacheDependency dependency = new CacheDependency(null, pageCacheDependencyKey); // Add to cache, without dependencies and expiration // policies. If the cached item should be cached for // limited time (regardsless of the cache dependency), // add an absolute expiration date or a sliding expiration // to the item. // Also note, we use the Insert method that will overwrite // any existing cache item with the same key. The Add method // will throw an exception if an item with the same key exists. HttpContext.Current.Cache.Insert(cacheKey, SOMETHING, dependency); /Steve
#14258
Mar 25, 2008 18:44
Vote:
 
VersionKey... Obvious when you say it. Brilliant. Thanks.
#14259
Mar 25, 2008 18:44
Vote:
 
What about delayed publish pages? From what I can see, when pages become expired (ie pass their publish stop date), their DataFactoryCache.VersionKey doesn't change, therefore the cache dependency isn't activated? Does anyone have a suggestion for how to handle this situation?
#14260
Mar 25, 2008 18:44
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.