Khaled
Khaled

Reputation: 851

Remove Output Cache Programmatically

I want to ask about the way to expire the output caching of a specific page programmatically regardless the expiration duration.

I found several posts and articles online regarding this issue and i found on this article that this line of code does the work

HttpResponse.RemoveOutputCacheItem("/caching/CacheForever.aspx");

I tried it several times, but it does not remove the output cache.

In the same demo there was another way to add the output cache using a key added as a cache dependency I tried it and it works fine, but I want to know why the RemoveOutputCacheItem method does not work. It seems that it is the one made to do that job, any ideas?

Upvotes: 1

Views: 1559

Answers (1)

Evert
Evert

Reputation: 8541

An old, but useful, question - your line of code worked for me, Thanks!

One of the instances where it would not work would be when you tell the outputcache to cache permanetly on the client machine using

HttpCacheability.Public or HttpCacheability.Private

Then the client would not go check for an updated file until its own cache is cleared, irrespective of what you do on the server side.

Upvotes: 1

Related Questions