Clear all cache in ASP.NET
The previous post was about advantage using cache in web application .Complex application must using cache to increase the performance of application. But sometime you a over heating the memory if so many information stored in cache and the cleaner(GC) need to clean up the mess. Unfortunately Garbage Collector(GC) not remove the cache, you need to do it by your self. The problem is how to get all key of the cache and then remove it.? So the solution is you need to use the IDictionaryEnumerator to get all of the cache key. Lets look at the method example. Feel free to try by your self. Clear Cache Method public void clearCache() { IDictionaryEnumerator dictionaryEnumerators = Cache.GetEnumerator(); if (dictionaryEnumerators.MoveNext()) { ...