Path Cache Key Indexing Bug

Bug found with Path Cache with Cache Key Indexing with Sitecore.

Path Cache Key Indexing Bug

A bug was found in Sitecore 9.x (Sitecore 9.1 and above) and in Sitecore 10.x when the Path Cache under Cache Key Indexing was enabled on Content Delivery servers on Sitecore.

<setting name="Caching.CacheKeyIndexingEnabled.PathCache" set:value="true" />

The issue occurs when an item is unpublished and later published to the publishing target or the Web database. The changes would not be available on Content Delivery servers for components dependent on them. It wasn’t until an Application Pool Recycle that these items became available.

For the components dependent on finding the item in the target database, these components would get the Sitecore Item by the path. As the developer community recommends, getting an item by path is not the best option. Sitecore maintains a path cache where the determined path of the item is mapped to its Item ID. Getting a Sitecore Item by Item ID is always better. But, sometimes, you can't get around it.

Cache Key Indexing is usually enabled for large solutions. It was enabled on the solution because Sitecore Support recommended it due to the large content database size and to solve a previous problem. But, ultimately, we found that Path Cache on Cache Key Indexing is something we could do without.

As part of troubleshooting, cache clears were inspected by reviewing records in the Event Queue table after a publish, and event records were processed by the Content Delivery servers.

After validating that the Event Queue was getting processed, a different approach was attempted by changing how the Sitecore Item was retrieved. It was found that the problem would show when Sitecore.Context.Database.GetItem("/sitecore/content/.../myitem") was used. The issue would not occur when Sitecore.Context.Database.SelectSingleItem("/sitecore/content/.../myitem") was used. SelectSingleItem will depend on the Item Cache. Upon inspecting the Item Cache, it would show the item on the Content Delivery server. So what is the difference between GetItem and SelectSingleItem?

After Sitecore Support did a bit of digging, it turned out to be the Path Cache. Inspecting the Path Cache on the Content Delivery server would show the path entry with the expected Item ID like {5727b4d2-0239-41ae-b982-dd9de31f30ab} when the path has never been in the cache.

But, when the item is unpublished, the path will be stored in the cache with an empty Guid.

/sitecore/content/.../myitem with the Item ID {00000000-0000-0000-0000-000000000000}

After republishing the item, the ID is never updated.

The Path Cache would not clear with the Cache Key Index enabled. web[paths] was not cleared on publishing.

Disabling the Path Cache under Cache Key Indexing solved this problem.

This issue is expected to be fixed at some point with later releases or a cumulative patch. The reference number of the bug report is 157425.

Hero Photo by Lauren Mancke on Unsplash