Need to purge cache without resetting IIS?? Below is a simple and effective C# code to help you on that.
The code snippet is helpful particularly on QA & Prod environments where you are not required to reset the IIS that frequently as you do on your local DEV machine.
public void PurgeCache() { List keys = new List(); IDictionaryEnumerator enumerator = Cache.GetEnumerator(); while (enumerator.MoveNext()) { keys.Add(enumerator.Key.ToString()); } for (int i = 0; i < keys.Count; i++) { Cache.Remove(keys[i]); } }
You can add this method on Page_Load() of an .aspx page and directly browse that page on IIS.
Further, you can restrict the access to this method based on IP@ so that it shouldn’t be publicly accessible.
(Visited 576 times, 1 visits today)