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.
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.
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.
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?
Please take a look at this question ans also info how stackoverflow does this can help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With