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.

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.

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

Trackbacks & Pingbacks

[…] 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 […]

[…] 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 […]

[…] 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?. […]

[…] 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?. […]

MY EPISERVER BOOK

EPISERVER NEWSLETTER

Connect

Hi, I'm Jon, I write articles about creating and optimizing websites as well as making money from your online business. I am technical architect and technology fanatic by profession. You can find out more about me by signing up to my newsletter.