A
Arpan
I am using the following code to cache the page output for 60 seconds:
<%@ OutputCache Duration="60" VaryByParam="*" %>
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
lblOutput.Text = "Welcome, " & Request.Params("id") & " The
time now is " & DateTime.Now.ToString("T")
End Sub
</script>
<form runat="server">
<asp:Label ID="lblOutput" runat="server"/>
</form>
Suppose I type the following URL in the address bar (assume that the
above ASPX page exists in C:\Inetpub\wwwroot\ASPX & is named
CacheOutput.aspx):
http://myserver/ASPX/CacheOutput.aspx?id=clive
Assume that the time shown is 2:43:18 PM. Ideally when I refresh the
page within a minute, the time should remain the same i.e. 2:43:18 PM.
Next I change the querystring value within a minute:
http://myserver/ASPX/CacheOutput.aspx?id=andrew
Now assume that the time shown is 2:43:40 PM. When I refresh the page
within a minute, the time should remain the same i.e. 2:43:40 PM.
Next I change the value of the querystring "id" back to "clive" within
a minute. The time shown should still be 2:43:18 PM (& not the current
time) since the page has been cached for a minute. Changing the "id" to
"andrew" again within a minute should show the time as 2:43:40 PM (&
not the current time).
But what I find is on some occasions, the page output gets cached
correctly for 60 seconds but on other occasions, the page either
doesn't get cached at all or it gets cached for a few seconds i.e. the
time shown continuously changes to the current time even when I refresh
the page within a minute.
What's causing this eccentricity?
Thanks,
Arpan
<%@ OutputCache Duration="60" VaryByParam="*" %>
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
lblOutput.Text = "Welcome, " & Request.Params("id") & " The
time now is " & DateTime.Now.ToString("T")
End Sub
</script>
<form runat="server">
<asp:Label ID="lblOutput" runat="server"/>
</form>
Suppose I type the following URL in the address bar (assume that the
above ASPX page exists in C:\Inetpub\wwwroot\ASPX & is named
CacheOutput.aspx):
http://myserver/ASPX/CacheOutput.aspx?id=clive
Assume that the time shown is 2:43:18 PM. Ideally when I refresh the
page within a minute, the time should remain the same i.e. 2:43:18 PM.
Next I change the querystring value within a minute:
http://myserver/ASPX/CacheOutput.aspx?id=andrew
Now assume that the time shown is 2:43:40 PM. When I refresh the page
within a minute, the time should remain the same i.e. 2:43:40 PM.
Next I change the value of the querystring "id" back to "clive" within
a minute. The time shown should still be 2:43:18 PM (& not the current
time) since the page has been cached for a minute. Changing the "id" to
"andrew" again within a minute should show the time as 2:43:40 PM (&
not the current time).
But what I find is on some occasions, the page output gets cached
correctly for 60 seconds but on other occasions, the page either
doesn't get cached at all or it gets cached for a few seconds i.e. the
time shown continuously changes to the current time even when I refresh
the page within a minute.
What's causing this eccentricity?
Thanks,
Arpan