OutputCache behaving strangely

F

frankswildyearstom

hello,

<%@ OutputCache Duration="3600" VaryByParam="none" %>

protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();
}

If, after I compiled this newly created application, browser B1 is
first to request Cache.aspx, then the time displayed on received page
is 10.16:20.
If, after say 10 seconds, I refresh B1’s Cache.aspx( by clicking a
button to cause a postback), then time 10.16.30 will show up, and on
all subsequent postbacks 10.16.30 will always be displayed ( until 1
hour elapses ).
If few minutes after B1 first requested Cache.aspx, browser B2 also
requests the same page, then upon receiving the page for the first
time, B2’s Cache.aspx will display time 10.16.20, and on all
subsequent B2’s postbacks time 10.16:30 will be displayed instead.

A) So it appears that Asp.net generates two cached versions of
Cache.aspx ( thus code is executed twice ), one cached page is given
to browsers that request Cache.aspx for the first time, and second
cached page is given to browsers which only refresh their Cache.aspx?


B) Since my book never mentioned such a behavior, I’m wondering if you
get the same behavior or is my Net environment again “unique”?

C) Creating two copies of same page ( thus executing the code twice )
seems like a waste of time, so why does Asp.Net operate like that –
there must be some reasoning/benefits behind it?


thank you
 
F

frankswildyearstom

Well, it seems that in Asp.Net 3.5 cache also differentiates between
POST and GET:

If Cache.aspx has both "< a href... >" and a button on a page, then on
first request time displayed is 10.20.30, and if I use "< a href... >"
for postbacks, Cache.aspx displays 10.20.30. But if 10 minutes later I
click on a button, then Cache.aspx displays time 10.30.30. Now if
postback is caused by "< a href... >", time displayed is always
10.20.30, if by button, then time is 10.30.30

-- Any idea if that is a bug or…?

-- Is it possible to turn that feature off (so that caching wouldn’t
differentiate between Post and Get)?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top