Tuesday 2 December 2008

Removing Items From the OutputCache

Today's learning point from StackOverflow:

Whilst it's clear that using output caching is a Good Thing, it can be a little counter-productive sometimes if a user changes some detail that invalidates the cached version of the page e.g. changing the price of a product, adding a new comment to a blog post. But as I've now discovered you can programmatically remove the cached version of the page by calling this static method on the Response stream:
Call HttpResponse.RemoveOutputCacheItem(myCachedUrl)

Looking it up on MSDN I discovered that this method has been present since .NET 1.1 and I've never come across it before!

No comments: