LibrarySites.Banner

Sitecore Output Cache Clearing Optimization (7/8): The OutputCacheClearingEventHandler Event Handler | John West | Sitecore Blog

This entry about the OutputCacheClearingEventHandler event handler that clears output caches is part of a series of blog posts about a custom approach to clearing output caches for managed sites with the Sitecore ASP.NET web Content Management System (CMS) and Experience Platform (XP). For more information, see the Resources section at the end of this blog post.

The OutputCacheClearingEventHandler event handler can clear or trawl output caches after at least publish:end, custom:publish:end:remote, indexing:end, and indexing:end:remote events. The IgnorePublishingTargets, IgnorePublishingLanguage, IgnoreIntervals properties support configuration by the factory, as do the AddMustContain() and AddMustNotContain() methods. The HandleEvent() method implements the handler, processing the OutputCacheClearingOptions passed to it (in the case of a custom:publish:end:remote event) or the OutputCacheClearingOptions property of the Sitecore.Sharedsource.Publishing.ClearSiteOutputCaches static class.

In the case of a local event, the handler first locks OutputCacheClearingOptions property of the Sitecore.Sharedsource.Publishing.ClearSiteOutputCaches static class, and then parses information from its context. If appropriate, this event handler raises the custom:publish:end:remote event. If further necessary, the OutputCacheClearingEventHandler event handler calls the ClearOutputCaches() method of the OutputCacheClearer class to invoke the clearOutputCaches pipeline, and then calls the Reset() method of the OutputCacheClearingOptions property of the Sitecore.Sharedsource.Publishing.ClearSiteOutputCaches static class before its use by the next publishing process.

Resources