
|
Solving a Caching And Expiring Problem By 15 Seconds Discussion List |
Rating: 3.9 out of 5 Rate this article
|
email this article to a colleague
suggest an article
|
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.
|
|
|
|
|
Supporting Products/Tools
|
|
|
CustomError 2.0 for IIS
|
|
When errors occur on a Web site, they should be handled in a way that helps the user to get back on track. Unfortunately, setting up customized error pages in IIS usually requires something many Web developers lack -- access to and familiarity with the Web server's administrative interface. With CustomError for IIS, developers can add error pages, coded by hand or created in their favorite editor, by simply uploading them to a designated directory. No administrator intervention is required.
|
[Top]
|
|
|
|
Other Articles
|
|
|
|
|
|
|
Jun 21, 2004 - Using Open Source .NET Tools for Sophisticated Builds
|
|
|
Building an application can be more than pressing F5. With an increasing
number of quality packages being released, developers for the .NET platform now have options to create a very sophisticated build process. Aaron Junod describes a sample build environment and shows how a number of tools can work together to make reliable, predictable, and value-added builds.
[Read This Article] [Top]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Apr 18, 2001 - Error Reporting - IIS 5.0
|
|
|
The script in Mark Newlands' article this week handles how errors are displayed and logged. It can capture all values in use at the time (e.g. form, querystring, session,and application level) and records them if you set a Boolean value to do so - displays custom HTML if required. Sends email, logs to database, and/or text file.
[Read This Article] [Top]
|
|
|
|
|
Mailing List
Want to receive email when the next article is published? Just Click Here to sign up.
|
|