How To Enable Cache Key Indexing
If you've got a website or a multi-site that is a particularly good size. Perhaps you have a lot of articles, or you've got a huge directory of individuals from your company. Then toss in a breadth of components each utilizing different templates and languages and versions. Sprinkle in items moving around, copied, deleted, you know the drill.
If this is sounding familiar and you're in Azure then cache key indexing can potentially help with any sluggishness that your site might be experiencing.
Note: It's always important to test configurations out in a pre-production environment before moving them to production.
What Is Cache Key Indexing?
Good question. Well, it's something that can significantly reduce the amount of time an operation would take to perform when dealing with a large cache. The more items that your site has, languages, etc, the larger your caches are likely to be. As such, as your site grows, you will see it get slower and slower. This is intended to combat that.
Don't go throwing this in everywhere though. If you've got a CM / CD environment and have more than a few authors, languages and version, then if you placed these settings on the CM environment it could actually do more harm than good.
There are four settings in Sitecore we can look into.
- Access Result Cache:
Caching.CacheKeyIndexingEnable.AccessResultCache
- Item Cache:
Caching.CacheKeyIndexingEnable.ItemCache
- Item Paths Cache:
Caching.CacheKeyIndexingEnable.ItemPathsCache
- Path Cache:
Caching.CacheKeyIndexingEnable.PathCache
By default these values are false, so we need to create a patch file like the one below ensuring it only runs on the ContentDelivery
role.
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
<sitecore role:require="ContentDelivery">
<settings>
<setting name="Caching.CacheKeyIndexingEnabled.AccessResultCache" value="true" />
<setting name="Caching.CacheKeyIndexingEnabled.ItemCache" value="true" />
<setting name="Caching.CacheKeyIndexingEnabled.ItemPathsCache" value="true" />
<setting name="Caching.CacheKeyIndexingEnabled.PathCache" value="true" />
</settings>
</sitecore>
</configuration>
And that's it. After you've done your testing, move it to your production environment, and if all goes well, you should see some improvement.