Sitecore prefetch cache

One area of Sitecore that doesn’t seem to get much attention is the Sitecore prefetch cache. Recently we’ve been investigating how to get the content editor working faster, especially with large content dbs. Under the hood Sitecore has prefetch caches for each database it uses. If you are tuning your site be sure to pay them some attention. The config files it uses live in /app_config/prefetch.

A word of caution before you begin, updating using the following approach can increase the app startup time dramatically. I’d recommend only applying within live environments as you don’t want to add minutes to app startup during dev. Another thing to be wary of is the cache sizes, during testing it wasn’t uncommon to reach 2000MB of data in the pre-fetch cache. If you tune up the capacities make sure you pay attention to other caches eg master[items] to ensure balance throughout the caching layer.

What does the prefetch cache give you out the box?

The ability to tune:

  • the size of the prefetch cache per database
  • the number of child items per children call
  • which items to cache
  • which items to load the children of
  • which items of template type to load

Depending on the setup of your Sitecore tree a combination of the above will need tuning.

Some tips

  • Speed up the CMS (master.config) media library by caching all the media folders:
  • Get a clear view of what is in all your caches with the more detailed admin page:
    https://marketplace.sitecore.net/en/Modules/Sitecore_Cache_Admin.aspx

What else can you do?
In most of our builds we setup a file which contains all the template ids we use in the app. An example would be:

This allows quick access to all the templates when asserting on specific content types. The following code maps this kind of file to the notation required by the prefetch cache configuration. When you run the page it will generate all the <template name=’… entries for the master.config.

Front end:

Back end:

How to build on this?
How about generating the config file during app startup?

Other info.
There is a detailed video from Sitecore at http://mediacontent.sitecore.net/wmv/CacheRecordingWebinar.mp4 about the caches. Alternatively read the Sitecore docs

2 thoughts on “Sitecore prefetch cache

  1. Have you never been interested in why sitecore is issuing checks like “… [ItemId] IN (SELECT [ID] …” which are performing extremely bad? Such kind of SQL statements make the database to work well up to hundreds of records but can show noticeable performance drops when tables reac even thousands of rows! Not to speak when they accumulate hundreds thusands of rows or even more!

    • These sort of things are probably worth bringing up with support. In the past we’ve run diagnostics onto the db’s and found in the most part that the indexes we’d expect are in place.

      One set of queries which we’ve seen to cause lots of rows being returned relate to when you have lots of languages and lots of versions as you get back fields for every permutation.

Leave a Reply

Your email address will not be published. Required fields are marked *