1

I am working on Sitecore SXA and we are planning to implement cache. I have enabled it on Site level and added cache on rendering level for all the sites inside tenant. Now my question is how can we check cache is enabled at browser level or check cache key somewhere in Sitecore (log file). How can we check its key (cache key)? Just want to check cache is working fine at our site?

4

2 Answers 2

2

There is no built in tool with Sitecore that allows you to easily inspect the cache keys that have been constructed in the HTML cache. To do this you need to write your own inspection page or tool. Alternatively you could install Sitecore Rocks – the tool that integrates with Visual Studio which allows you to view the cache keys. To do this Manage your site from within the Visual Studio Sitecore Explorer and select the caches tab. Scroll down to “yoursitename[html]” and double click it. The Explore cache window should appear and you should then be able to see the cache keys currently in the cache e.g.:

enter image description here

You can also check cache details on the below paths :

https://hostname/sitecore/admin/stats.aspx

https://hostname/sitecore/admin/cache.aspx

1
  • Thank you for your answer.
    – Nisha
    Jun 8 at 15:17
0

The processor used by default on Sitecore does not log the cache key to the logs. The best you can do here is to patch the processor which generates the cache key with a custom processor. It would go something like below:

LogCacheKey.cs

using Sitecore.Mvc.Pipelines.Response.RenderRendering;
using Sitecore.Mvc.Presentation;

namespace HabitatHome.Foundation.Caching.Pipelines
{
    public class LogCacheKey: GenerateCacheKey
    {
        public GenerateCustomCacheKey(RendererCache rendererCache) : base(rendererCache)
        {
        }
        protected override string GenerateKey(Rendering rendering, RenderRenderingArgs args)
        {
            var cacheKey = base.GenerateKey(rendering, args);
            // Add logging here
            Sitecore.Diagnostics.Log.Info($"Cached the rendering {rendering.RenderingItem.Name} with cacheKey {cacheKey}");
            return cacheKey;
        }
    }
}

HabitatHome.Foundation.Caching.config

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
    <sitecore>
        <pipelines>
            <mvc.renderRendering>
                <processor patch:instead="processor[@type='Sitecore.Mvc.Pipelines.Response.RenderRendering.GenerateCacheKey, Sitecore.Mvc']"
                                type="HabitatHome.Foundation.Caching.Pipelines.LogCacheKey, HabitatHome.Foundation.Caching" resolve="true" />
            </mvc.renderRendering>
        </pipelines>
    </sitecore>
</configuration>

This is only a rough idea, you can include more information as required in the logs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.