dkarzon
dkarzon

Reputation: 8038

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?

Upvotes: 3

Views: 5368

Answers (4)

Paul Hiles
Paul Hiles

Reputation: 9778

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.

Upvotes: 5

JP.
JP.

Reputation: 5606

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)

Upvotes: 0

longda
longda

Reputation: 10423

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)

Upvotes: 0

Adam Tuliper
Adam Tuliper

Reputation: 30152

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

Upvotes: 0

Related Questions