谁能告诉我是否可以跨多个页面缓存 RenderPartial?我有一个用于用户配置文件的 RenderPartial,除非用户更新其配置文件,否则它实际上不会改变。所以我真的不想每次加载页面时都回去获取他/她的个人资料。我宁愿传递部分内容,直到我被迫更新(即配置文件更新)
我查看了 DonutHole p.haack 放在一起的示例,但它似乎与单个页面相关。有人可以指出我正确的方向或提供任何建议吗?或者我一次只能缓存一页?谢谢!
Can anyone tell me if its possible to Cache a RenderPartial across multiple pages? I have a RenderPartial for a user profile that shouldn't really ever change unless the user updates their profile. So i dont really want to go back and get his/her profile every time i load a page. I would much rather pass the partial around until im forced to update (i.e. profile update)
I looked at the DonutHole example that p.haack put together, but it seems to be relevant for a single page. Can someone point me in the right direction or offer any advice? Or am i only able to cache one page at a time? thanks!
发布评论
评论(1)
您可以改用 RenderAction。示例:
在
Index.cshtml
和About.cshtml
视图中,您可以包含子操作:并且您将在两个页面中获得它的缓存版本。
You could use RenderAction instead. Example:
and inside the
Index.cshtml
andAbout.cshtml
views you could include the child action:and it you will get the cached version of it in both pages.