Is Donut caching available in ASP.NET MVC 3

后端 未结 4 1619
滥情空心
滥情空心 2020-12-05 20:14

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 th

相关标签:
4条回答
  • 2020-12-05 20:48

    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.

    0 讨论(0)
  • 2020-12-05 20:57

    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

    0 讨论(0)
  • 2020-12-05 20:57

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

    0 讨论(0)
  • 2020-12-05 20:58

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

    0 讨论(0)
提交回复
热议问题