views:

72

answers:

0

My website pages are composed of two kinds of content. The first is variable between users but constant for all pages. The second is constant across users, but variable between pages. This is a common layout. What is the best way to apply output caching to content like this?

As I understand it, the Html.Substitute helper is incompatible with the MVC2 rendering pipeline, eliminating the old way of donut caching.

Use normal output caching with VaryByParam="user" for every page?

The level of specificity would reduce the value of output caching. It's unlikely that the same user will view the same page very many times within the lifespan of the cached output.

Use a alternate OutputCache subsystem

There are several attempts floating around the internet that modify the OutputCache attribute and rendering subsystem to support substitution. The best one I've found is here.

However, the various snippets I've found seem to be informal implementations, and aren't well supported. Additionally, I'm inclined to suspect that if it were that easy to add substitution back into the MVC2 pipeline, it would've been done.

Compose the final page from several child actions which are individually cached

The action method would not be flagged with an OutputCache attribute, and would return a view which contains several Html.RenderAction invocations which would pull in independently cached content. Aside from the slightly heavyweight implications of using RenderAction, it would add an extra layer of indirection and a code smell.

What is your experience with composing independently cached content in MVC2? What's worked well and what hasn't?

related questions