ASP.NET Performance Tips
page 6 of 19
by Adiseshu Dasari
Feedback
Average Rating: 
Views (Total / Last 10 Days): 75322/ 136

Page output caching

If you have an ASP.NET page that generates output, whether HTML, XML, images, or any other data, and you run this code on each request and it generates the same output, you have a great candidate for page output caching.

Simply add this line to the top of your page.

Listing 1

<%@ Page OutputCache VaryByParams="none" Duration="60" %> 

Now the above effectively generates the output for this page once and reuses it multiple times for up to 60 seconds.

This reduces the number of database hits and improves the performance of page load.
There are several configurable settings for output caching, such as the VaryByParams attribute just described. VaryByParams just happens to be required, but allows you to specify the HTTP GET or HTTP POST parameters to vary the cache entries. For example, default.aspx?Report=1 or default.aspx?Report=2 could be output-cached by simply setting VaryByParam="Report." Additional parameters can be named by specifying a semicolon-separated list.


View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-25 10:20:37 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search