There are 2types of caching for ASP.NET
1. Configuring Page-Level Cachingcopy the code below to aspx html source page
<%@ OutputCache Duration="15" VaryByParam="none" %>
Duration means the duration of the cache. In this case, it will cache for 15 seconds.
the name "AppCache1" will be used to the pages that you want to have cache. You can have different kinds of cache options by just adding another profiles like the code below
what we have to do in each of our page is add the code below
<%@ OutputCache CacheProfile="AppCache1" VaryByParam="none" %>
Note: the name of the
CacheProfile is the name you set in
outputCacheProfiles in web.config.
The attribute
VaryByParam is used for caching parameters (eg. querystring) of a page.
example:
<%@ OutputCache Location="Server" Duration="60" VaryByParam="Color" %>
Here we have a param called "Color".
(http://mysite/mypage.aspx?Color=red)When user goes to the page wtih Color=red, it caches the page with param Color=red for specific duration according to our setting.
If we specify the VaryByParam parameter, any new value will be cached. For cached value, it loads data from cache.
Here's the detail explanation of VaryByParam from Microsoft MSDN
==================================
The @ OutputCache directive requires you to set the
VaryByParam attribute, which until you now you have set to "none". The VaryByParam attribute enables you to configure caching so that ASP.NET stores different versions of a page depending on parameters such as query strings, form post values, request headers, and so on.
For example, you can use cache parameters in a page that displays weather conditions for select cities, where the weather data is refreshed only every three hours. In this scenario, you want to cache a separate version of the page for each city. You can do so by setting the cache parameter to vary by a query string parameter.
==================================
If you wish to study all the details on your own see
here