LibrarySites.Banner

Sitecore Output Cache Clearing Optimization (3/8): The clearOutputCaches Pipeline | John West | Sitecore Blog

This entry about the clearOutputCaches pipeline used to clear output caches for managed sites 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.

Processors in the clearOutputCaches pipeline inherit from the abstract ClearOutputCachesProcessor abstract base class and implement the DoProcess() method accepting an argument of type ClearOutputCachesArgs args. The Process() method in the base class invokes the DoProcess() method and then aborts the pipeline if no output caches remain to be processed. This pipeline assembles a list of output caches and then processes it.

The OutputCacheSite class provides access to managed sites and their output caches. This includes:

  • The minimum interval allowed between cache clearings by this process.
  • The date and time of the last clearance of the cache by this process and the CacheHasExpired property to determine whether the interval has passed since the last cache clearing by this process or if the cache has not previously been cached by this process.
  • A SiteContext property representing the managed site.
  • The HtmlCache associated with the managed site.
  • The IsLanguageRelevant() method to determine if a language is relevant to the site.
  • The LastClearedKey property used to store the date and time in the cache after its clearance, to determine if the interval has passed since the last clearance of the cache by this process.
  • A method to determine if a publishing target is relevant to the managed site.

The clearOutputCaches pipeline contains the following processors:

  • GetOutputCacheSites: Populates a list of managed sites with output caches.
  • CheckPublishingLanguage: Removes entries from the list if the clearOutputCacheAfterPublishingLanguages attribute of the managed site indicates languages other than that associated with the publishing operation.
  • CheckPublishingTarget: Removes entries from the list if the database associated with the managed site differs from that associated with the publishing operation.
  • CheckInterval: Removes entries from the list if the outputCacheMinimimInterval attribute of the managed site has not expired since the cache was last cleared by this process or does not indicate when it was last cleared by this process.
  • ClearCaches: Unless CacheKeysMustContainOne or CacheKeysMustNotContainAny contains a value, clears output caches and aborts the pipeline.
  • TrawlOutputCacheKeys: Invokes the scavengeOutputCacheKey pipeline for each entry in each output cache indicated by a ClearSiteOutputCaches object that I hope to describe elsewhere.

Resources