[英]Load html content of master page in next pages
I have a requirement where i want to increase the performance of the page because my master page is heavily loaded with controls taken from the database. 我有一个要提高页面性能的要求,因为我的母版页面上载满了从数据库中获取的控件。
I want to save the HTML output of the master page so that i can use the HTML for loading to other pages which uses the master page thus reducing the time taken for loading the page. 我想保存母版页的HTML输出,以便可以将HTML加载到使用母版页的其他页面上,从而减少了加载页面所需的时间。
Is it possible.? 可能吗。? if possible any reference. 如果可能的话任何参考。
I searched for same online but could get some irrelevant content. 我在网上搜索了相同内容,但可能会得到一些不相关的内容。
Use Asp.Net Output Caching You can cache entire pages or page fragments (usercontrols). 使用Asp.Net输出缓存您可以缓存整个页面或页面片段(用户控件)。
ASP.NET allows you to cache some or all of the response generated by an ASP.NET page, referred to in ASP.NET as output caching. ASP.NET允许您缓存由ASP.NET页生成的部分或全部响应,在ASP.NET中称为输出缓存。 You can cache the page at the browser making the request, at the Web server responding to the request, and at any other cache-capable devices, such as proxy servers, that are in the request or response stream. 您可以在发出请求的浏览器上,在响应请求的Web服务器上以及在请求或响应流中的任何其他具有缓存功能的设备(例如代理服务器)上缓存页面。 Caching provides a powerful way for you to increase the performance of your Web applications. 缓存为您提供了一种强大的方式来提高Web应用程序的性能。 Caching allows subsequent requests for a page to be satisfied from the cache so the code that initially creates the page does not have to be run again. 高速缓存允许从高速缓存满足对页面的后续请求,因此不必再次运行最初创建该页面的代码。 Caching your site's most frequently accessed pages can substantially increase your Web server's throughput, commonly measured in requests per second. 缓存站点中最常访问的页面可以大大提高Web服务器的吞吐量,通常以每秒请求数来衡量。
Thisi is a small example just to explain how it works: 这是一个小示例,仅用于解释其工作方式:
in order to cache a page's output, use the @OutputCache directive at the top of the page: 为了缓存页面的输出,请在页面顶部使用@OutputCache指令:
<%@ OutputCache Duration=5 VaryByParam="None" %>
you can increase the performance of ASP.net Application by using caching feature 您可以通过使用缓存功能来提高ASP.net应用程序的性能
you can increase the cache of master page by adding in following lines in masterpage cs file 您可以通过在母版页cs文件中添加以下行来增加母版页的缓存
protected void Page_Load(object sender, EventArgs e)
{
Response.Cache.SetExpires(DateTime.Now.AddMonths(1));
Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate);
Response.Cache.SetValidUntilExpires(true);
}
saving html is not a good idea 保存html不是一个好主意
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.