Cache ASP.Net Tutorial

The VaryByParam attribute causes a  new instance of a page to be cached when a different parameter is passed to the page. 
File: Master.aspx
<%@ Page Language="C#" %>
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


    Master


    
    

            id="grdProducts"
        DataSourceID="srcProducts"
        AutoGenerateColumns="false"
        ShowHeader="false"
        GridLines="none"
        Runat="server">
        
                    DataTextField="Title"
            DataNavigateUrlFields="Id"
            DataNavigateUrlFormatString="~/Details.aspx?id={0}" />
        

    
            id="srcProducts"
        ConnectionString="<%$ ConnectionStrings:Products %>"
        SelectCommand="SELECT Id,Title FROM Products"
        Runat="server" />
    

    


File: Details.aspx
<%@ Page Language="C#" %>
<%@ OutputCache Duration="3600" VaryByParam="id" %>
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


    Details


    
    

    <%= DateTime.Now.ToString("T") %>
    
            id="dtlProduct"
        DataSourceID="srcProducts"
        Runat="server" />
            id="srcProducts"
        ConnectionString="<%$ ConnectionStrings:Products %>"
        SelectCommand="SELECT * FROM Products
            WHERE Id=@Id"
        Runat="server">
        
                            Name="Id"
                Type="int32"
                QueryStringField="Id" />
        

    
    

    


You can assign two special values to the VaryByParam attribute:
none: causes any query string or form parameters to be ignored. 
      
*:    caches a new cached version whenever there is a change in query string or form parameter passed to the page.
You can assign a semicolon-delimited list of parameters to the VaryByParam attribute.