-1

I tried to use this code for clear cache but It not working with Google Chrome. I need to clear all cache in browser or clear all website cache (not only one page) Ps: Most of code using widget DOJO javascript that why I need to clear all cache.

List<string> keys = new List<string>();
// retrieve application Cache enumerator
IDictionaryEnumerator enumerator = Cache.GetEnumerator();
// copy all keys that currently exist in Cache
while (enumerator.MoveNext())
{
  keys.Add(enumerator.Key.ToString());
}
// delete every key from cache
for (int i = 0; i < keys.Count; i++)
{
  Cache.Remove(keys[i]);
}
HttpRuntime.Close();

Thank you for every answers.

  • I don't think you can remove cache of the browser. It will very browser to browser. But you can set cache time for your resources of you application. – शेखर Sep 22 '15 at 05:46

1 Answers1

0

You can try like this to clear all cache of the browser

HttpContext.Current.Response.AddHeader("Cache-Control", "no-cache, no-store, must-revalidate");
HttpContext.Current.Response.AddHeader("Pragma", "no-cache");
HttpContext.Current.Response.AddHeader("Expires", "0");

You can also refer: Making sure a web page is not cached, across all browsers

Community
  • 1
  • 1
Rahul Tripathi
  • 152,732
  • 28
  • 233
  • 299