Is Donut caching available in ASP.NET MVC 3
Asked Answered
F

4

12

ASP.NET MVC 3 (final) was released today. When this version was in its infancy I remember reading on codeplex that donut caching was being considered. Does anyone know if this made it into V3? I cannot seem to find any information so I can only (sadly) assume that it didn't happen.

Fichu answered 13/1, 2011 at 22:11 Comment(1)
Let me get this right, donut caching has been available since .NET 2. MVC2 supports it. MVC3 drops support?! What on earth for? With no alternatives available other than writing it all yourself? Gah, that can't be right.Fatimafatimah
B
15

Yes, it is. Scott Gu blogged about it:

In addition to supporting full page output caching, ASP.NET MVC 3 also supports partial-page caching – which allows you to cache a region of output and re-use it across multiple requests or controllers. The [OutputCache] behavior for partial-page caching was updated with RC2 so that sub-content cached entries are varied based on input parameters as opposed to the URL structure of the top-level request – which makes caching scenarios both easier and more powerful than the behavior in the previous RC.


UPDATE:

Out of the box only donut hole caching is supported in ASP.NET MVC 3. This allows you to cache a small portion of the page by using the [OutputCache] attribute on a child action. Donut caching which allows for excluding portions of a page that has been cached is not supported. Response.WriteSubstitution doesn't work since ASP.NET MVC 2. Here is a good article which explains the different caching options available in ASP.NET MVC 3.


UPDATE 2:

Here's a great article which illustrates how donut caching could be enabled in ASP.NET MVC 3.

Brainless answered 13/1, 2011 at 22:13 Comment(2)
This is donut hole caching, not donut caching. Donut caching is not supported in-box in MVC 3.Szabadka
@Darin, Thanks for the update. An excellent article indeed. I read somewhere that the goal is to include donut caching in MVC 4. not sure whether to hold out or use this nuget package...Fichu
G
2

Here's a slightly more detailed example from Scott, using Razor syntax.

Gelation answered 15/1, 2011 at 6:4 Comment(1)
Great link but not sure if this is donut hole caching, since the page isn't cached but the "donut hole" is. I don't want to cache parts of my page, but instead cache the page and leave parts dynamic. It's a nuance, but one that should be clarified.Nyctophobia
P
2

Donut Caching (yes, the real thing) is available as part of my 'speed-lib' for MVC: Moth. Works in both ASP.NET MVC 2 and MVC 3.

Docs are at the wiki, and examples are in the Mvc3.Demo folder

Prize answered 9/8, 2011 at 10:12 Comment(0)
C
2

I found a NuGet package MvcDonutCaching mentioned by Denis Huvelle which solves the problem for 3 & 4 - but I haven't tested it.

Cullender answered 25/1, 2013 at 10:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.