How to clear all HttpContext Cache items?

“HttpContext.Current.Cache” has a metod to remove items one by one with their key names.

If you want to remove all items from the cache you can use this little code snippet to achive this task:

IDictionaryEnumerator enumerator = HttpContext.Current.Cache.GetEnumerator();

while (enumerator.MoveNext())
{
    HttpContext.Current.Cache.Remove(enumerator.Key.ToString());
}

Happy coding…

P.S.: This techique don’t effect the output cached pages.

Posts created 141

Leave a Reply

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top