在内容和主页面输出缓存 [英] Output cache in content and master page

查看:106
本文介绍了在内容和主页面输出缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两个问题:

1 如果我有母版页的母版页的内容页,我把我的内页的内容:

1. If I have a content page of master page of master page and I put inside my content page:

<%@ OutputCache ...%>

是否缓存整个页面或只有内容页面部分?

Does it cache the whole page or only the content page portion?

2 如果我想在母版页级应用OutputChace,我怎么能做到这一点?
我有很多内容页面使用它的母版页。我想申请上所有的人都一样的OutputCache配置文件,但我不想去逐一和改变他们。

2. If I want to apply OutputChace in the master page level, how can I accomplish this? I have a master page that a lot of content pages uses it. I want to apply the same outputcache profile on all of them, but I dont want to go one by one and change them.

感谢。

推荐答案

整个页面缓存。
修改


您可以使用用户控件缓存的部分。

The whole page is cached. Edit
You can use user controls to cache portions.

正如评论,如果你想缓存使用特定的母版页的所有页面,则需要在母版页以下code

As by the comments, if you want to cache all pages that are using a specific master page, you need the following code in the master page

 protected void Page_Load(object sender, EventArgs e)
        {
            Response.Cache.SetExpires(DateTime.Now.AddMonths(1));
            Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate);
            Response.Cache.SetValidUntilExpires(true);
        }

这篇关于在内容和主页面输出缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆