This is a sample demo that I have created to try explaining myself about VaryByParam attribute of OutputCache:

The Markup:

```
<%@ OutputCache Duration="10" VaryByParam="ID" %>

<asp:Button ID="SetQueryStringButton1" runat="server" 
                Text="Set query string ID=1 and redirect"
                PostBackUrl="~/OutputCachingUsingQueryString/Default.aspx?ID=1" />
    <br />
    <asp:Button ID="SetQueryStringButton2" runat="server" 
                Text="Set query string ID=2 and redirect"
                PostBackUrl="~/OutputCachingUsingQueryString/Default.aspx?ID=2" />
    <br />
    <asp:Button ID="SetQueryStringButton3" runat="server" 
                Text="Set different query string and redirect"
                PostBackUrl="~/OutputCachingUsingQueryString/Default.aspx?ABCD=3" />

```

The Code-behind:

```
if (IsPostBack)
    {
        string key = Request.QueryString.GetKey(0);
        MessageLabel.Text = "The value of query string " + key + " is : " + Request.QueryString[key] + "<br/>";
        MessageLabel.Text += DateTime.Now.ToLongTimeString();
    }

```

When I click first two buttons, then according to the definition of VaryByParam, it caches the page for ID = 1 and ID = 2. But when i click the third button, it does cache the page for ABCD = 3.
What i was expecting is the page shouldn't be cached for ABCD=3, because I haven't specified it in VaryByParam. I get the same dateTime when i repeatedly click the third button.

**EDIT START**:
I also tried it this way:

The Markup:

```
<%@ OutputCache Duration="10" VaryByParam="ID" %>
<asp:Label ID="MessageLabel" runat="server"/><br/>
<a href="Default.aspx?ID=1">Click Me and pass ID=1</a><br/>
<a href="Default.aspx?ID=2">Click Me and pass ID=2</a><br/>
<a href="Default.aspx?ABCD=3">Click Me and pass ABCD=3</a><br/>

```

The Code-behind:

```
if (!IsPostBack)
{
   if (Request.QueryString.Keys.Count > 0)
   {
      string key = Request.QueryString.GetKey(0);
      MessageLabel.Text = "The value of query string: " + key + " is: " +  Request.QueryString[key] + "<br/>";
      MessageLabel.Text += DateTime.Now.ToString();
   }
}

```

When I click the third , it displays the MessageLabel after I click it couple of times. Some kind of weird behavior I am experiencing here.

**EDIT END**

Please shed some light on what wrong I am doing?
Thanks in advance.