Optimize or disable the Prefetch caches

Current version: 10.1

Applies to

Content Delivery, Content Management

The Prefetch caches are initially populated on application startup and continue to be populated during the lifetime of the application. The list of items to prefetch is defined for each database in the configuration files in the <wwwroot>/App_Config/Prefetch/ folder.

Note

Read more about optimizing and disabling the initial population of the Prefetch caches in the Excessive load on the Core database after application restart knowledge base article.

Prefetching too many items increases the load on the SQL server and can degrade application startup time. To avoid this, you can:

  • Optimize the initial population of the Prefetch caches.

  • Disable the initial population of the Prefetch caches.

Optimize the initial population of the Prefetch caches

You optimize the initial population of the Prefetch caches by only including the most frequently accessed items.

Use the following elements to determine which items are included:

Element

Description

Multiple elements allowed

<template>

This element includes all items based on a specific template.

Yes

<item>

This element includes the specified item.

Yes

<children>

This element includes the child items of a specified item.

Yes

<childLimit>

This element limits the number of child items that can be cached for each parent item.

No

The following is a sample patch file containing the Prefetch caches configuration elements:

RequestResponse
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"
               xmlns:set="http://www.sitecore.net/xmlconfig/set/"
               xmlns:role="http://www.sitecore.net/xmlconfig/role/">
    <sitecore>
        <databases>
            <database id="web">
                <dataProviders>
                    <param desc="headProvider">
                        <dataProvider param1="$(id)">
                            <prefetch hint="raw:AddPrefetch">
                                <template desc="sample">{<template GUID="">}</template>
                                <item desc="root">{<item GUID="">}</item>
                                <children desc="main sections">{<item GUID="">}</children>
                                <childLimit>100</childLimit>
                            </prefetch>
                        </dataProvider>
                    </param>
                </dataProviders>
            </database>
        </databases>
    </sitecore>
</configuration>

Disable the initial population of the Prefetch caches

If you disable the initial population of the Prefetch caches, they are still populated when items are accessed by visitors.

To disable the initial population:

  1. Replace all element under the configuration/sitecore/databases/database/dataProviders/dataProvider/prefetch elements with a <patch:delete /> element.

  2. Add an new <prefetch> element with the following global elements:

    Element

    Description

    Mandatory

    <cacheSize>

    This element configures the maximum initial Prefetch cache size. If it is not specified, it defaults to the value of the Caching.DefaultDataCacheSize setting.

    No

    <childLimit>

    This element limits the number of child items that can be cached for each parent item.

    Yes

    <logStats>

    When this element is set to true, advanced diagnostics information is logged as:

    RequestResponse
    Count: <number of added items>, Template: <template GUID>

    Yes

The following is a sample patch file containing the Prefetch caches configuration elements:

RequestResponse
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"
               xmlns:set="http://www.sitecore.net/xmlconfig/set/"
               xmlns:role="http://www.sitecore.net/xmlconfig/role/">
    <sitecore>
        <databases>
            <database id="web">
                <dataProviders>
                    <param desc="headProvider">
                        <dataProvider param1="$(id)">
                            <prefetch hint="raw:AddPrefetch">
                                <patch:delete />
                            </prefetch>
                            <prefetch hint="raw:AddPrefetch">
                                <cacheSize>1000MB</cacheSize>
                                <childLimit>100</childLimit>
                                <logStats>false</logStats>
                            </prefetch>
                        </dataProvider>
                    </param>
                </dataProviders>
            </database>
        </databases>
    </sitecore>
</configuration>

Do you have some feedback for us?

If you have suggestions for improving this article,