Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing Page Cache in ASP.NET

For my blog I am wanting to use the Output Cache to save a cached version of a perticular post for around 10 minutes, and thats fine...

<%@OutputCache Duration="600" VaryByParam="*" %> 

However, if someone posts a comment, I want to clear the cache so that the page is refreshed and the comment can be seen.

How do I do this in ASP.Net C#?

like image 943
GateKiller Avatar asked Aug 14 '08 19:08

GateKiller


People also ask

What is a way to cache an ASP.NET page?

To manually cache application data, you can use the MemoryCache class in ASP.NET. ASP.NET also supports output caching, which stores the generated output of pages, controls, and HTTP responses in memory. You can configure output caching declaratively in an ASP.NET Web page or by using settings in the Web. config file.


1 Answers

I've found the answer I was looking for:

HttpResponse.RemoveOutputCacheItem("/caching/CacheForever.aspx"); 
like image 103
GateKiller Avatar answered Oct 05 '22 16:10

GateKiller