Donut Caching Tutorials

2k views Asked by At

Can someone point out a couple of good quality tutorials/pages for donut caching? Like everything else on the web, you can google a million things, but several of the articles I've found are a bit confusing.

I'm looking for

  1. What is donut caching
  2. When should you use it
  3. How do you implement in ASP.net
4

There are 4 answers

3
Johnno Nolan On BEST ANSWER

Donut caching is where you cache every thing on a page except a few dynamic regions. So you cache the doughnut but not the hole.

You should use it when most of you page is static other than 1 changable section.

You should read this on implementation advice.

0
Joel Martinez On

I'm not sure that you're going to get better results by using stackoverflow as a human powered search engine. Honestly, anything that anyone here will post will be sourced from a search engine query such as this one:

http://www.bing.com/search?q=asp.net%20donut%20caching

0
TheVillageIdiot On
  1. article by Phil Haack (asp.net mvc)
  2. article by ScottGu on asp.net weblogs
  3. implementing donut caching on wackylabs

and all this with one google search

0
PhilPursglove On

I'm not sure I'd go so far as to call it a good tutorial but if you watch this video there's a short demo of how to write donut caching at about 36 minutes in.

How to do it boils down to:
Add output caching to your pages.
Decide what items need injecting into your cached pages before they get returned to the client.
For each item, create a static (Shared in VB) method that returns the item e.g.

Public Shared Function LoginName(ByVal context As HttpContext) As String

    Return "Welcome, " & context.User.Identity.Name

End Function

Add a Substition control to your page in the appropriate location for each item, which calls the method you just created.

<asp:Substitution runat="server" ID="LoginNameSubstitution" MethodName="LoginName" />

And you're done!