开发者

MVC3 Partial with no caching on page with caching

In my MVC3 Project I use some output caching with the OutputCache attribute set on the action. However there are certain sections on this page that I dont want to cache ever.

Is it possible to have开发者_开发问答 some partials in my view that overrides the pages caching?


You can now get proper donut caching by downloading the MvcDonutCaching NuGet package. See http://mvcdonutcaching.codeplex.com/ and http://www.devtrends.co.uk/blog/donut-output-caching-in-asp.net-mvc-3 for more information.


Yes you are 'supposed' to be able to do this. See: Partial Views Caching in ASP.NET MVC 3

Also I use a method to disable caching for controllers here:

Disable browser cache for entire ASP.NET website


Seems like this is the answer: http://weblogs.asp.net/scottgu/archive/2006/11/28/tip-trick-implement-donut-caching-with-the-asp-net-2-0-output-cache-substitution-feature.aspx

You basically have two options:

  1. Refactor the page so that rather than caching the entire page, you identify all the specific pieces (controls, partials, etc) that should be cached. (boo)
  2. Use output substitution blocks as Scott Guthrie describes in the link. (boo as well unless the replacement is just simple text)


This is called donut caching and isn't supported out of the box in MVC3. Check out my similar question here. Specifically, Jan Jongboom's Moth library which he suggests can do this (though I cannot confirm or deny this)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜