Skip to the content

Umbraco 8 Donut Cache

This article was following on from Paul Seal’s article about Umbraco 7 donut cache which was in turn taken from for Umbraco Uk Festival 2018. As usual thanks Paul for all your hard work in the community and the time you put into this great content.

https://codeshare.co.uk/blog/how-to-use-donut-caching-in-umbraco-and-mvc/

What is Umbraco 8 Donut Caching?

Donut caching is simply a technique used to cache MVC actions. This technique is great to speed up your site by caching MVC actions / partial views that do not update that often. Some good examples might be your top navigation and footer navigation.

How to get up and running with Umbraco 8 Donut caching.

You can pretty much work from Paul’s original tutorial. In terms of getting up and running there is not much difference (if any). The only thing that will have changed from what I can see is how to clean out the cache. I am pretty sure the event handlers have changed slightly in Umbraco 8 to 7.

Here are the steps I took to get up and running.

Install MvcDonutCaching

Install the following nuget package to your project ‘Install-Package MvcDonutCaching

Add some Web.Config config

Add the following settings to your web.config. Add these within the system.web tag.

<caching>
      <outputCacheSettings>
        <outputCacheProfiles>
          <add name="FiveMins" duration="300" varyByParam="*" />
          <add name="OneHour" duration="3600" varyByParam="*" />
          <add name="OneDay" duration="86400" varyByParam="*" />
         <add name="OneWeek" duration="604800" varyByParam="*" />
          <add name="OneMonth" duration="2629746" varyByParam="*" />
          <add name="SixMonths" duration="15778476" varyByParam="*" />
          <add name="OneYear" duration="31556952" varyByParam="*" />
        </outputCacheProfiles>
      </outputCacheSettings>
</caching>

Decorate your MVC actions

Now decorate your MVC actions with the following.

[DonutOutputCache(CacheProfile = "OneMonth")]

Here is an example of one of my MVC actions to give you a better idea of what needs to happen.

[ChildActionOnly]
[DonutOutputCache(CacheProfile = "OneMonth")]
public ActionResult RenderTopNav()
{
       SiteSettings settingsDoc = SiteSettings)GetSettingsDocument();
       return PartialView("~/Views/Partials/Shared/TopNav.cshtml", settingsDoc);
}

Conclusion

Donut caching in Umbraco 8 works very well and its highly recommended. It will really help speed up your websites if implemented carefully. It will help get your overall page load times down, help reduce http requests, and really help boost your ratings when clients run their site through the various SEO checking sites such as Google Page Insights etc.

I hope this article was useful.

If you need any further assistance please feel free to reach out to me directly or leave some comments below.

About the author

David Armitage

Umbraco Community Builder | .Net MVC Developer | Umbraco Certified Master | Recruitment Professional

Hey Peeps,

I'm an entrepreneur and web developer with a passion for coding. I absolutely love working with Umbraco CMS and appreciate the Umbraco community even more.

I've got 10 years+ .Net experience and 7 years+ experience working in the recruitment industry, both coding and marketing job websites. I wanted to use my skills to help give something back to this awesome community and so I decided to build UmbraJobs.com.

My vision & fundamentals

I want this website to be a place where Umbraco Professionals and Umbraco Partners can advertise their services but at the same time I want to filter out all the under-qualified freelancers & agencies that take up the biggest part of other job & freelancer websites. We've all worked hard to gain our Umbraco certifications, partnership status, and help build the Umbraco community to what it is today. I want to see everyone get rewarded for their efforts.

Follow me on social media

If you're an Umbraco professional, partner, employer, recruiter or a passionate Umbraco community builder then I'm more than happy to hear from you. Follow me on my social media channels and please reach out if you have any needs, want help or consultation with anything Umbraco related or just want a general chat.

comments powered by Disqus

Blog Filter


How we can help?

Need help with an Umbraco project?

Need help with a project but not too sure who to approach? Send us your project brief and budget. We will provide a free consultation and can help you gather quotes from the best and most suitable freelancers or agencies.

Looking to hire an Umbraco Professional?

Have you got job vacancy and want to hire an Umbraco professional? Post a job on our website for free. Alternatively let us know your requirements and we will send suitable prospects your way.

Claim your free profile!

Are you an Umbraco Freelance Developer or Umbraco partner that wants to advertise on our site? If you work with Umbraco or registered as an Umbraco partner then you can create a profile for free.

Let's build the Umbraco Community

We're big on building the Umbraco community and we think you guys are awesome! If there's anyway at all we can help then please reach out.