Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Donut caching available in ASP.NET MVC 3

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.

like image 469
JP. Avatar asked Jan 13 '11 22:01

JP.


People also ask

What is donut caching?

Donut caching is a server-side caching technique in which the entire page is cached, except for small portions that remain dynamic.

How cache is implemented in ASP.NET MVC?

In ASP.NET MVC, there is an OutputCache filter attribute that you can apply and this is the same concept as output caching in web forms. The output cache enables you to cache the content returned by a controller action. Output caching basically allows you to store the output of a particular controller in the memory.

What are the types of caching in C#?

ASP.NET supports three types of caching: Page Output Caching [Output caching] Page Fragment Caching [Output caching] Data Caching.


2 Answers

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.

like image 155
Darin Dimitrov Avatar answered Oct 03 '22 19:10

Darin Dimitrov


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

like image 38
friism Avatar answered Oct 03 '22 20:10

friism