How to verify what’s inside your Sitecore Rendering Cache

I recently found myself doing some performance optimisations around renderings in Sitecore, one of which involved caching. Having spent time cache tuning some renderings I wanted to prove the cache contained the HTML markup I expected . Unfortunately Sitecore doesn’t let you view the contents of the HTML cache without writing some custom code. 

Sitecore Rocks to the rescue! To view the keys in Sitecore rocks select the caches tab from the Sitecore Explorer and scroll down to “yoursitename[html]” and double click. The “Explore cache” window will appear and you should then be able to see the cache keys currently in the cache. Sitecore Rocks will display the cache keys but unfortunately not the cached HTML that is stored against them.

Sitecore Rocks allows you to see the cache keys in use but not the corresponding markup

So i decided to knock up a (very) quick and dirty admin page in the same vein as the standard Sitecore admin pages. This can simply be dropped in the Sitecore admin folder and when browsed to, will display a list of cache keys and respective cached HTML for a given site. I’ve submitted this page as a module in the Sitecore Marketplace that is easy to download and use. It’s also on Github.

Custom cache viewer allows you to view the markup stored against each cache key
Custom Cache Viewer allows you to view the markup stored against each cache key

To use:

  • Download the module from the Marketplace when approved or from Github
  • Copy the aspx file to the /sitecore/admin folder in your installation
  • Browse to /sitecore/admin/htmlcacheviewer.aspx
  • Select a cache from the list of site caches in the drop down listThe page will automatically update to show the current cache keys and values in the selected HTML cache 
  • To order the cache keys alphabetically ascending or descending click the cache key column header
  • For those cache keys that include a Sitecore GUID such as when Varying by Datasource a clickable link is generated that will dump you into the content editor and select the item in question.
  • To copy the HTML markup to the clipboard for further analysis click the copy button for the row you wish to copy.
  • The list of cache keys is retrieved when first selected, so to refresh to show the current state click the Refresh link under the drop down list of caches.

Let me know if you find it useful (or not!)

Leave a Reply

Your email address will not be published. Required fields are marked *