0

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.

Cassini
  • 75
  • 2
  • 3
  • 15
  • Do you mean something like [include](http://www.php.net/manual/en/function.include.php)? – Déjà vu Mar 26 '14 at 10:43
  • Sounds like you should look into database caching. – Sam Axe Mar 26 '14 at 10:45
  • check this [link](http://stackoverflow.com/questions/6575819/output-cache-in-content-and-master-page) – Nikhil K S Mar 26 '14 at 10:50
  • i don't want to display the html for same page again. the master page which has asp controls shouldn't be loaded again and again. In my case i have repeaters for menu controls and content for footer and left hand menu. So for any page i have to use the html generated master page instead of using the actual one. – Cassini Mar 26 '14 at 11:18

2 Answers2

0

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" %>
  • Duration - The time in seconds of how long the output should be cached. After the specified duration has elapsed, the cached output will be removed and page content generated for the next request. That output will again be cached for 5 seconds and the process repeats.
  • VaryByParam - This attribute is compulsory and specifies the querystring parameters to vary the cache. To specify multiple parameters, use semicolon or * for all parameters passed through the querystring
giammin
  • 18,620
  • 8
  • 71
  • 89
0

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

Nikhil K S
  • 806
  • 1
  • 13
  • 27
  • i want to save html only for content of master page only and bind it for remaining page. Caching can help when same page is loaded again. i want it for any other page using master page. – Cassini Mar 26 '14 at 11:19
  • i think saving html and placing that in other page is a difficult process – Nikhil K S Mar 26 '14 at 11:27
  • but it is my requirement as my page performance is very poor and takes almost 15- 20 secs to load the repetitive content in all pages. – Cassini Mar 26 '14 at 11:29
  • you can call database only once by using [sigleton](http://stackoverflow.com/questions/14932387/ensure-singleton-call-db-query-only-once) object – Nikhil K S Mar 26 '14 at 11:29