Output cache in content and master page

前端 未结 2 635
一生所求
一生所求 2021-01-20 06:38

Two questions:

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

<%@ OutputCache ...%>
         


        
2条回答
  •  悲哀的现实
    2021-01-20 07:01

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

    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);
            }
    

提交回复
热议问题