Sometimes you need to clear all the cached
from the browser in ASP.NET application in order to save new entry is available
in the cache.
The method you use is actually clear your cache.
public
void ClearCacheItems()
{
List<string>
keys = new List<string>();
IDictionaryEnumerator enumerator =
Cache.GetEnumerator();
while (enumerator.MoveNext())
keys.Add(enumerator.Key.ToString());
for (int i =
0; i < keys.Count; i++)
Cache.Remove(keys[i]);
}
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

Ankush ChauhanPosted Jul 15, 2020, 7:29 AM
Can you confirm that above code is clearing all cache from site means of all pages cache?
Piyush MunjalPosted Dec 20, 2017, 8:47 AM
Where to call this method?
Surender GusainPosted Oct 31, 2014, 9:31 AM
thanks, it works for me