Sitecore caching

Challenge:

Caching is not only the most important bit in Sitecore. But also not well documented [They are working on it!]. We always worked hard to understand the caching and tried to use caching up to its fullest extent.

Would like to share our findings in this article.

Solution:

All Sitecore Caching Basics: It’s always good to know the basic concepts deeply to become expert in any topic. So, before we move on to become Sitecore caching expert. Let’s understand the basics of Sitecore Caching.

This is the diagram — Which I always look at whenever I would like to clear my Sitecore Caching Concepts.

So what and when are things actually cached? Well look at this graph, which shows how a request is handled.

  1. If the item which is requested has presentations which are cached, the HTML from the HTML cache is returned and the request is ended.
  2. If there isn’t any HTML cached all items needed by the presentation is requested from the item cache.
  3. If the items aren’t in the item cache it is retrieved from the data cache and parsed into an Sitecore.Data.Items.Item and stored in the item cache.
  4. If the item isn’t present in the data cache, it is retrieved from the prefetch cache and the ItemInformation is stored in the data cache.
  5. If the item isn’t in the prefetch cache it is retrieved from the database and stored in the prefetch cache as PrefetchData.

To read more about Sitecore caching. You must read :

http://learnsitecore.cmsuniverse.net/en/Developers/Articles/2009/07/CachingOverview.aspx

How Can you check what’s your cache size? Or get Caching Statistics?

Cache Administration Page

The Cache Administration page provides information about each of the Sitecore caches. You can use the Cache Administration page to monitor Sitecore cache utilization and to clear the Sitecore caches.

You can access the Cache Administration page at the following URL: http:///sitecore/admin/cache.aspx
Replace <hostname> with the hostname of your CMS server.

The Rendering Statistics Page

The Rendering Statistics page provides information about each of the renderings for which an entry exists in each site HTML (output) cache. You can use the rendering statistics page to identify under-performing renderings and renderings for which you can improve cache configuration.
You can access the Rendering Statistics page at the following URL: http:///sitecore/admin/stats.aspx

Replace <hostname> with the hostname of your CMS server.

Update[2nd March 2012]:

“Sitecore Items cache[Level2 from top in earlier shown diagram] stores formed Item objects, Data cache [Level3] stores Item data objects – something like item for all versions, Prefetch cache [Level4] stores item fields, child list, and something like raw data. In our case only item cache gets cleared, there will be no additional database requests, in case if required data is in , Data cache [Level3] or in the Prefetch cache [Level4]. So, we are going to increase cache size for Data cache [Level3] and Prefetch cache [Level4]. So, it will serve the data from cache only rather than talking to database[Level5] directly.”

What should be the ideal cache size?
It depends on your server environment. But the basic rule is  Bigger Cache Size == better performance

You can use Cache Configuration Reference:
http://sdn.sitecore.net/upload/sitecore6/sc62keywords/cache_configuration_reference_a4.pdf

If you are the guy/gal who hates to read and loves to watch, This Sitecore caching webinar recording is for you:
http://sitecoreaustralia.wordpress.com/2010/06/28/cache-webinar-recording/

Good to read :

http://sitecore.spaces.live.com/default.aspx?_c11_BlogPart_BlogPart=blogview&_c=BlogPart&partqs=cat%3DCaching&sa=178587253

Cache Sizing:
http://sdn.sitecore.net/SDN5/Articles/Administration/Sitecore%20Performance/Caching/Cache%20Sizing.aspx

Caching options:
http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2010/12/Caching-Options-in-the-Sitecore-ASP-NET-CMS.aspx

I hope you found this article useful. If you have any question Or have good caching link/document/knowledge which you would like to share with others. Please do share!

Happy Sitecore Caching! 🙂

16 thoughts on “Sitecore caching

  1. Pingback: Publishing and Cache Clearing Basics « Sitecore basics!

  2. Pingback: Basics of Cache Size Tuning « Sitecore basics!

  3. Pingback: Basics of Sitecore Startup « Sitecore basics!

  4. Pingback: Cache Tuner User Guide « Sitecore basics!

  5. Pingback: Is your HTML Cache working? « Sitecore basics!

  6. Pingback: Does your CM server performing slow? « Sitecore basics!

  7. Pingback: Basics of HTML Caching « Sitecore basics!

  8. Vk

    Thanks for providing the above information. After reading your post I have a question that if my Sitecore database is down for 2 or 3 min and If a user requests a page at the same time(when database is down) will Sitecore render the page from cache or is it going to throw an error saying database is down. I am assuming that it will throw an error but why does it need to do a database transaction when the page is already in Cache.

    1. kiranpatils

      Thanks for the nice words!

      I haven’t tried it. But I agree that it will throw exception as DB is down and as per my view it is correct. Because for few things Sitecore will be surely contacting DB.

      But still I would suggest you to give a go and check what happens, please do share your results with us.

      Happy Sitecoring! 🙂

      Keep visiting, Keep reading and Keep sharing!

      Kiran

  9. Pingback: Why I love Sitecore? « Sitecore basics!

  10. Pingback: Basics of Sitecore full cache clearing « Sitecore basics!

  11. Wow that was strange. I just wrote an really long comment but after I clicked submit my comment didn’t appear. Grrrr… well I’m not writing all that
    over again. Anyhow, just wanted to say superb blog!

    1. kiranpatils

      Thank you for the appreciation, it matters a lot!

      Keep visiting! Keep reading! Keep sharing!

      Sincerely.
      Kiran Patil

Leave a comment