|
Jamie Writes:
I'm using IE5.5, and I'm trying to make the page refresh even if someone
hits the back button on the browser. I'm also stuck behind MS Proxy Server.
I've tried the following:
Response.Expires=0
Response.Expires=-1
Response.ExpiresAbsolute=#1/1/1980#
Response.CacheControl="Private"
Response.CacheControl="Public"
And just about all combinations of the above
Is this possible? I'm looking for a solution that would work on IE4+
Jamie Replies to Himself With:
For some reason, I did not search MSDN before, it lead me to this:
<% Response.CacheControl = "no-cache" %>
<% Response.AddHeader "Pragma", "no-cache" %>
<% Response.Expires = -1 %>
I think that should fix it.
Eric Provides An Even Better Solution!
The code from MSDN below will work good for IE. This works a little better
in all browsers...
<%
Response.ExpiresAbsolute = #1/1/1980#
Response.AddHeader "cache-control", "no-store, must-revalidate, private"
Response.AddHeader "Pragma", "no-cache"
%>
One other consideration. If you want the page to automatically refresh when
they hit BACK, the page that is in the history also must not have been
created as a result of a POST operation. Otherwise the user will receive an
error before it reposts the information. Therefore, you should try not to
use POST on the previous page for any pages you want the user to be able to
move back to.
Page 1 (GET Method) ==> Page 2 (not cached) ==> Page 3
When the user hits the back button on page 3, page 2 will automatically be
called from the server, (assuming the user has not configured his or her
browser to always cache pages.)
Page 1 (POST method) ==> Page 2 (not cached) ==> Page 3
When the user presses the back button on page 3 the user will receive an
error that the previous page resulted in a POST operation. The message will
prompt them to REPOST the information from page 1.
Work around:
Page 1 (post back to page 1 then redirect to page 2) ==> Page 2 (not cached)
==> Page 3
When the user presses back here, it acts the same as using the GET method
above. The disadvantage is that it requires two trips between page 1 and
page 2.
A Stumped Gregory Enquires Further:
Eric,
I understand everything until the last part (your workaround)
Page 1 (post back to page 1 then redirect to page 2) ==> Page 2 (not
cached)
==> Page 3
Forgive me for being a little confused but how would I do that? I have
pages with this very scenario and I'd like to implement this alternative.
Can you give a few lines of code? I guess I don't understand "post back to
page 1 then redirect to page 2". I appreciate any help you could give :)
Now an Expert, Jamie Clarifies:
I think he means have your post's action argument post right to the same
page.
Then, during your handling of the post method, redirect to page 2.
Then, if they hit the back button, they would just go back to page 1, the
post method wouldn't be called again (the page would just get refreshed).
This conversation string was taken from the 15Seconds ASP Listserv on 2/1/01. If you have
an ASP-related question or would like to share some of your knowledge with others, you may
join the list by clicking here.
|