I'm using asp.net 4.0 (Web Forms website) and I've implemented a custom disk based output provider which works fine in caching the pages on my site. The problem I'm getting however is that I cannot find a way to remove a specific page from the cache and I suspect it's a problem with Url Rewriting.
For example, if I have a page called test.aspx, I can easily remove it from the cache using:
HttpResponse.RemoveOutputCacheItem("/test.aspx");
This does not work for a page that is output cached through id though eg http://www.example.com/page/1 is rewritten as http://www.example.com/myfolder/Page.aspx?id=1
I can see the cached version of the page but I cannot remove it from the disk cache as I need an absolute virtual path for RemoveOutputCacheItem to work. I've tried the following:
HttpResponse.RemoveOutputCacheItem("/myfolder/Page.aspx?id=1");
HttpResponse.RemoveOutputCacheItem("/myfolder/page/1");
And a lot of other variations but nothing seems to work.
The cached key for the url does not match the stored key a2_myfolder_page.aspxHQNidV1FCDE when trying to use RemoveOutputCacheItem.
Is there any solution for that? Or another way to get specific cached pages evicted? Thanks