Only cache MasterPage in ASP.NET MVC
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 techniq开发者_StackOverflowue using ASP.NET MVC to achieve the same goal?
Thanks in advance.
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?
精彩评论