Episerver Caching – Output Caching Strategies Explained…. What Is a Donut Cache?

In the previous articles I’ve talked about how to use the Output cache to cache objects in your website.  When applying an output caching strategy there are several paths that you can consider:

Full Page Caching

In a full page solution, you use the built-in OutputCache attribute on your Episerver page type controller and the whole page is cache. In most basic brochureware type sites this is usually the route I would recommend. It is also the simplest, I would recommend reading Episerver Caching – The Output Cache Explained

Donut Hole Caching

In certain situations, caching a whole page might not be the best approach. For example, in an e-commerce project, if you change the price of an item in stock and that item is displayed on many pages, invalidating the whole page isn’t the most efficient use of your cache.  Say your website has 20 different languages and the product in question appears on 5 pages.

When you update the price of your product, you have a dilemma.. one, you have to invalidate 20 pages * 5 pages, so 100 pages. (language variations * pages affected).  In an extremely high load site, this would cause you a stampeding herd effect where 10,000 people might all request these pages at the same time and your web server has to go off and re-generate the whole page.

Instead of getting the web server to generate the whole pages HTML again, instead we can create a donut cache.  Donut caching comes in two flavors:

Partial Page Caching- Donut Caching

In donut caching you cache the whole page except the areas that change very frequently.

Partial Page Caching- Donut Hole Caching

In donut hole caching you never cache the full page, instead you cache parts of a page.  If you put the output cache attribute on one or more of your blocks then you are using a donut hole approach.

homer-and-donut

Donut Caching in Episerver

Now we have a clear idea about the different strategies of caching, it is up to you to decide what solution is most relevant to your website.  In general, the higher amount of traffic your site experiences and how dynamic and frequent your pages update, will be the biggest factor.  If you have an e-commerce site and want your prices displayed in real time, then donut caching is your best bet.  If you have pages that rarely ever update, then full-page caching is usually your best option.

If after reading this you have decided to go with a donut based approach, then I would recommend reading, Episerver Caching – How To Generate Custom Keys For Partials For Output Caching. . I will warn you now you have to worry about​ things like cache invalidation which can be very tricky. Good Luck!

Jon D Jones

Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge

More Posts

4 replies

Trackbacks & Pingbacks

  1. […] talked about when and why you may not use ‘full page‘ caching and why you might want to implement donut caching. In this post, I’m going to cover an EpiServer donut caching package that I have created and […]

  2. […] the fourth post in a series of posts covering EpiServer output caching; I would recommend reading EpiServer Caching – Output Caching Strategies Explained…. What Is a Donut Cache? to understand some of the needs as to why you might want to create a custom output cache […]

  3. […] In any high load website how you deal with your cache is kinda important. In most website scenarios you might consider using the out-of-box MemoryCache and this works fine in the majority of cases, however, depending on your project there are a few situations where Redis provides better value. On a recent project, I was asked to look into implement a Redis cache solution. Implementing Redis is actually surprisingly easy with .NET. In our situation, we wanted to cache HTML partial snippets in Redis due to it’s better scaling with large amounts of data. It’s probably worth saying that the reason behind this approach was to use a donut hole cache output provider. The idea of this EpiServer Caching – Output Caching Strategies Explained…. What Is a Donut Cache?. […]

  4. […] In any high load website how you deal with your cache is kinda important. In most website scenarios you might consider using the out-of-box MemoryCache and this works fine in the majority of cases, however, depending on your project there are a few situations where Redis provides better value. On a recent project, I was asked to look into implement a Redis cache solution. Implementing Redis is actually surprisingly easy with .NET. In our situation, we wanted to cache HTML partial snippets in Redis due to it’s better scaling with large amounts of data. It’s probably worth saying that the reason behind this approach was to use a donut hole cache output provider. The idea of this EpiServer Caching – Output Caching Strategies Explained…. What Is a Donut Cache?. […]

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

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