Attention: We are retiring the ASP.NET Community Blogs. Learn more >

How to : Dynamically Remove ASP.NET Page Output Cache Entries

I have sought for a perfect solution for a long time and eventually get following old links :

-

--- Truely , I get what I need : a simple method :

public static void HttpResponse.RemoveOutputCacheItem( string path )

I just need it to flush an in-caching page when a post-back-action triggering . For example , in an article-comments page context , normally it is cached ; however , when a user post a new comment , process is expected to have the cached version overthrown and welcome a new generated one to ensure display of fresh comments ---- whether current cache version expires or not. After flushing , the new version keeps to the rules of caching game.

To dynamically remove a page output cache through this method always meets thorny problems in traditional "honest page" context : it will remove all versions of a single page which are varied by params ( mostly ,querystring ). For example , a user visits page

~/article.aspx?articleId=100

and makes a comment , thread's calling above method may evict thouthand of articles pages ( with different articleId ) from cache but what I really need is just the flush of target article !

It is indeed a trouble and out of my idea; However , using the fresh , exciting asp.net 3.5 "Routing" technology can perfectly circumvent the rock , making things smooth : "article/100" and "article/101" are treated as two different pages. Since "Different versions of the same page" becomes "Different pages" , we will not have "outputCache-queryString-version" nightmare any more !

Later I will make a series of posts to discuss the application of asp.net 3.5 "web-form-based routing" technology.

2 Comments

Comments have been disabled for this content.