views:

216

answers:

4

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
A: 

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

Joel Martinez
+4  A: 

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.

John Nolan
I've always thought the opposite: you cache the hole (or the jam, depending on the type of doughtnut :-) ) and use Substitution controls to change what's round the outside. It depends on your page layout and where the most expensive bit of your page (to build) is I suppose.
PhilPursglove
Thanks. I think the initial explanation of the concept is what I was missing. None of the articles (listed below) really start at the high level and drill down. You start out neck deep in implementation and specific libraries.
Russell Steen
@PhilPursglove, you're thinking of "Donut Hold Caching" :-P http://haacked.com/archive/2009/05/12/donut-hole-caching.aspx
Joel Martinez
+3  A: 
  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

TheVillageIdiot
A: 

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!

PhilPursglove