How to patch Sitecore Database Prefetch Caches

Much was said about Sitecore Database Prefetch Caches, but there is something that I missed in most of the articles I read. How to add custom prefetches without changing the default Sitecore prefetch files (Common.config, Core.config, Master.config and Webdb.config).

In this article, I’ll be sharing a little bit about Sitecore prefetch cache and how to patch a custom prefetch.

What is cache prefetching

Cache prefetching is a technique to boost execution performance by fetching data from their original storage in slower memory to a faster local memory before it is actually needed (hence the term ‘prefetch’).

Different than the caching technique where it stores the data in memory from the first request, prefetching stores data once the application starts.

Sitecore has prefetch caches for each database it uses (Core, Master and Web). The configuration files it uses are located in \Website\App_Config\Prefetch.

How does it affect your application

If you prefetch a lot of content, each app restarts will take longer, because it is populating the prefetch. Bigger Prefetch gives slow startup, but it can give you better performance while opening Content Editor or Page Editor because your items’ data are already fetched from Database to Prefetch Cache.

If you have very little in the prefetch, app restarts will be quick. Smaller Prefetch gives fast startup, but it can give you less performance while opening Content Editor or Page Editor because your items might not be fetched to prefetch from the database.

The recommendation is only applying custom prefetch within live environments as you don’t want to add minutes to app startup during development.

When to use prefetch

You should use prefetch in the Homepage, for example, as it is the most frequently visited page. You should prefetch Home item and its immediate children.

Also, a News pages should be prefetched as it is supposedly visited frequently. You should prefetch “News Template” and their children, for example.

How can I see how much prefetch is currently being used

If you open the page /sitecore/admin/Cache.aspx and search by the word “prefetch” you’ll see an entry similar to “SqlDataProvider – Prefetch data(master)” and how much cache it is using.

How to patch

Basically, you just need to add all your customization under the node configuration/sitecore/databases/database[@id=”name”]/dataProviders/dataProvider/prefetch.

While it seems somehow overkill, I prefer this approach as you have a clear separation between Sitecore default configurations and yours. Also, it is quite handy to have it in a separate file as you don’t want your configuration overwritten by Sitecore during an upgrade, for example.

See below one custom prefetch in the Web database. I’ve created a configuration file named “zzz.CompanyName.Prefetch.Webdb.config” in “\Website\App_Config\Include\zzz.CompanyName” and added the following:

<configuration xmlns:patch="">
      <database id="web" singleInstance="true" type="Sitecore.Data.DefaultDatabase, Sitecore.Kernel" patch:source="Sitecore.Buckets.config">
        <dataProviders hint="list:AddDataProvider">
          <dataProvider ref="dataProviders/main" param1="$(id)">

            <prefetch hint="raw:AddPrefetch">

              <item desc="homePage">{13C27CC5-4C4D-4D16-8785-86E39147AEB2}</item>

              <item desc="configurationRoot">{B4F4CF01-5457-410A-9156-7FC2B6BA253D}</item>

              <item desc="dictionaryDomain">{0A2847E6-9885-450B-B61E-F9E6528480EF}</item>

              <item desc="navigationRoot">{5959BF8B-4AFC-43DA-8627-43445922AEE3}</item>
              <children desc="navigationRoot items">{5959BF8B-4AFC-43DA-8627-43445922AEE3}</children>



In this file I am defining that Sitecore will do prefetch up to 20MB. Also I am defining some items to be prefetched through the nodes “” and defining that the children of the item with the GUID “{5959BF8B-4AFC-43DA-8627-43445922AEE3}” will be prefetched.

I strongly recommend you to read the article “How to speed up Sitecore application startup” from Yougesh Patel for more information about how to prefetch items, children and templates.

That’s my short contribution to the Sitecore cache prefetching subject.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s