Wednesday, August 24, 2016

Sitecore tip on the web database prefetch cache

Sitecore has a number of different caching areas which all work together to (hopefully) provide a seamless CMS experience with reasonable load times for content editors and end users alike. Sitecore explains the prefetch caches rather well as:
Prefetch caches are populated at application initialization, based on the information provided in the prefecth configuration files. This results in a smoother user experience after an application restart.However, excessive use of the prefetch cache can increase the time required for the application to restart, giving a negative user experience.
To understand how the prefetch caches are utilized once the application is up and running, a view into how Sitecore caching works is required:
When a database item cache does not contain an entry for an item, Sitecore retrieves the corresponding entry from the database data cache, converts it to a different type, and stores that converted data as an entry in the database item cache. When the database data cache does not contain an entry for an item, Sitecore retrieves the corresponding entry from the database prefetch cache, converts it to a different type, and stores that converted data as an entry in the database data cache. When an entry does not exist for an item in a database prefetch cache, Sitecore retrieves that item from the data provider for that database, converts it to a different type, and stores that converted data as an entry in the database prefetch cache.
What this means is that the prefetch caches are not only populated at initialization, but during the life of the application. This understanding is required when thinking about setting the size of the prefetch caches.
In the Website\App_Config\Prefetch folder of your Sitecore website there are three files which define the prefetch cache for the web, core and master databases. Here the maximum size for the caches is set as well as some other options:
  • <template> — This element tells Sitecore to cache all items based on a given template at application initialization.
  • <children> — This element tells Sitecore to cache all of the children of the specified item. 
By default, the web database prefetch will be configured to cache the default home item and all of it's children. However in many instances that home item is deleted or left unused. Therefore the tip is to investigate which items or templates you want cached for the web database of your Sitecore instance. In many cases, having the main home item and it's children will lead to performance benefits.

Remember that it also leads to a slower application startup which is not as much as a worry for production as development.

No comments:

Post a Comment