Remove outputcache based on profile


Is that possible?
Closed Sep 11, 2013 at 4:12 PM by moonpyk


jogai wrote Aug 29, 2013 at 8:28 AM

Or an option to add tags to the cache attribute wich in turn can be used to remove caches..

moonpyk wrote Sep 11, 2013 at 4:12 PM

This can already be done by specifying a VaryByCustom attribute, call it "Profile"(http://msdn.microsoft.com/library/system.web.configuration.outputcacheprofile.varybycustom.aspx), implement it in your Global.asax, making it return the current UserIdentity/Group string.

Then later, when you need to invalidate your cache items, create one instance of OutputCacheManager and call RemoveItems("<YourController>", "<YourAction>", new { Profile="<profileToClean>" }); on it.