For high performance sites it can be catastrophic to clear all pages in the cache, here is a sample code to disable that functionality.
References
EPiServer extensions for the output cacheSelf-invalidating object cacheEPiServer CMS Remote eventsCaching in EPiServer CMSCached user control that expires when a page is publishedTroubleshoot EPiServers build-in output cacheEPiServer CMS 6 and above
CacheManager.ClearCacheOnLoadBalanceEventMissed = false;
EPiServer CMS 5
Event e = Event.Get(CacheManager.RemoveFromCacheEventId);
FieldInfo infoMissed = e.GetType().GetField(
"Missed",
BindingFlags.NonPublic | BindingFlags.Instance);
EventHandler handler = (EventHandler)infoMissed.GetValue(e);
MethodInfo removeMethod = typeof(CacheManager).GetMethod(
"RemoveFromCacheEvent_Missed", BindingFlags.Static | BindingFlags.NonPublic);
if (removeMethod == null)
{
throw new ApplicationException(
"Can't find method for EPiServer to clean the cache, EPiServer probebly upgraded");
}
foreach (EventHandler h in handler.GetInvocationList())
{
if (h.Method == removeMethod)
{
e.Missed -= h;
}
}