Showing posts with label performance. Show all posts
Showing posts with label performance. Show all posts

Tuesday, 3 February 2015

Sitecore pipelines in high volume sites

Introduction


If you use class-level variables in your Sitecore pipelines you might discover inconsistent and unwanted behaviour.

Using .net caching with Sitecore

Introduction


Sitecore has an extensive caching framework that allows it to cache everything from items in its database all the way to the html output of its renderings.  When using Sitecore's cache framework it employs a number of techniques to ensure that the cached data remains valid, and if you use .net's own caching framework this can sometimes conflict with Sitecore.  For example, let's say you have a menu control that appears on every page so you use .net's output caching to cache the html.  If a content editor changes something in Sitecore that affects your menu such as creating new elements, renaming titles etc, then your site is going to continue serving up the cached version which is no longer valid.  If you use Sitecore's own caching framework by setting cache parameters on the rendering then Sitecore will clear these cached items when a publish happens, ensuring that the cached html is rebuilt using the new data.  Furthermore, Sitecore will disable caching when you are in preview or edit mode so you know your data is always fresh.

As well as html caching, you might want to cache data structures you have built from Sitecore items.  Let's say you have a list of countries and in each country is a list of cities and you use this data often, so would like to cache it.  If you use .net caching and the underlying data in Sitecore changes, your cached data is now invalid.  You could set an expiry on the cache, but that's far from ideal as you don't want to tell your content editors that they have to wait before they see their changes go live.
In this article I am going to show you how to hook into the publishing mechanism such that your cached items are removed when a publish occurs.