开发者

Only cache MasterPage in ASP.NET MVC

开发者 https://www.devze.com 2022-12-17 22:03 出处:网络
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 Master

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消