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

Back to top
var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-35662136-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();