views:

325

answers:

1

I have a MasterPage that has ViewData passed to it. I would really like to cache only the MasterPage for performance reasons. But I do not want to cache the actual page that is loading with the MasterPage.

I believe this can be done in web forms by adding code in to the Page_Load event. Does anyone know of a similar technique using ASP.NET MVC to achieve the same goal?

Thanks in advance.

A: 

Hey,

When you mean by cache only the master page, do you mean output caching or cache only the ViewData related to the master page? You can use session or cache mechanisms to cache master page data, but you would have to programmably pick out what belongs to the master and what is there for the view.

If you are talking output caching, I don't believe output caching is available for master pages. For partial output caching in ASP.NET MVC, Steve Sanderson has some excellent points on this: http://blog.codeville.net/2008/10/15/partial-output-caching-in-aspnet-mvc/

So which type of caching are we talking about?

Brian
I was referring to something similar to output caching. Doesnt look like it is possible so as you say I will have to stick to other caching techniques.
Joel Cunningham