Sitecore uses type caching to optimize the cache size calculation. This results in an incorrect calculation of the cache size for JSON renderings added to the HTML cache. The issue might cause an HTML cache memory leak.
To confirm that the solution is affected by this particular issue:
- Collect a memory dump file.
- Check for a discrepancy between the actual cache size from the memory dump file and the estimated cache size shown on the /sitecore/admin/cache.aspx page.
To resolve the issue, consider one of the following options:
- Upgrade your solution to Sitecore XP 10.4 and Sitecore Headless Rendering 22 or later.
- Do the following:
- For Sitecore XP 10.3 and Sitecore Headless Rendering 21, download and install the cumulative hotfixes for the Sitecore Headless Services module that are available in KB1003184.
- Improve the accuracy of the cache size calculation by adjusting the following settings:
- Increase the cache size calculation depth using the following setting:
<setting name="LayoutService.CacheCalculationDepth" value="7" patch:source="Sitecore.LayoutService.config" />
The default value is "7". Note that the complexity of the cache size calculation grows with increasing the value of this setting. At some point it might affect the application response time.
- Multiply the size of each cache size entry by a fixed value using the following setting:
<setting name="LayoutService.JsonCacheMultiplier" value="1" patch:source="Sitecore.LayoutService.config" />
The default value is "1". This approach is not precise and might lead to significant swings in an estimation of an individual cache size entry. We recommend that you tune this setting after adjusting the "LayoutService.CacheCalculationDepth" setting.
Notes
- The values of the settings must be changed by creating a configuration patch file in the \App_Config\Include\zzz folder.
- Potentially you might need to adjust these settings in the future. This depends on the nesting level of the page layout components. The amount of content or the number of components on a page does not matter.