Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually clear ASP.NET server cache for a single application/web site?

How can I manually clear ASP.NET server cache (IIS 7) on a given application/website, like what can be done in IE to clear browser cache for a given domain?

like image 889
Faith Wins Avatar asked Mar 11 '11 16:03

Faith Wins


People also ask

What can you use to manually cache application data in asp net?

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

Use the following to remove all objects from the cache

IDictionaryEnumerator enumerator = HttpContext.Current.Cache.GetEnumerator();  while (enumerator.MoveNext()) {      HttpContext.Current.Cache.Remove((string)enumerator.Key);  } 

Also, it is a bit of a sledgehammer option but you can restart the entire application as follows:

System.Web.HttpRuntime.UnloadAppDomain(); 
like image 180
NakedBrunch Avatar answered Sep 21 '22 17:09

NakedBrunch