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.