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.
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 allows you to cache some or all of the response generated by an ASP.NET page, referred to in ASP.NET as output caching. 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. Caching provides a powerful way for you to increase the performance of your Web applications. 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.
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 Duration=5 VaryByParam="None" %>
you can increase the performance of ASP.net Application by using caching feature
you can increase the cache of master page by adding in following lines in masterpage cs file
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.