Invalidating ASP.NET OutputCache

You can invalidate ASP.NET output level cache using cache dependencies.
 
The ASP.NET webform should contain something like this:
 
<%@ OutputCache Duration="60" Location="Server" VaryByParam="None" %>
 
If you need to invalidate the cache prior to the 60 seconds elapsing you can do this by setting up a cache dependency between the page and an item in the cache:
 

Response.AddCacheItemDependency(“MyCachedData”)

 

Now, when the “MyCachedData” cachekey is changed or invalidated the cached page is invalidated too.

Leave a Reply

Your email address will not be published. Required fields are marked *