Donut caching, the ability to cache an entire page except for a small region of the page (or set of regions) has been conspicuously absent from ASP.NET MVC since version 2. Mmmmm, donuts! – Photo by Pzado at sxc.hu This is something that’s on our Roadmap for ASP.NET MVC 4, but we have yet to flesh out the design. In the meanwhile, there’s a new NuGet package written by Paul Hiles that brings donut caching to ASP.NET MVC 3. I haven’t tried it myself yet, so be forewarned, but judging by the blog post,...
UPDATE: Due to differences in the way that ASP.NET MVC 2 processes request, data within the substitution block can be cached when it shouldn’t be. Substitution caching for ASP.NET MVC is not supported and has been removed from our ASP.NET MVC Futures project.
This technique is NOT RECOMMENDED for ASP.NET MVC 2.
With ASP.NET MVC, you can easily cache the output of an action by using the OutputCacheAttribute like so. [OutputCache(Duration=60, VaryByParam="None")]
public ActionResult CacheDemo() {
return View();
}
One of the problems with this approach is that it is an all or nothing approach....