Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 08, 2010 08:53 AM by talktoanil
Aug 01, 2006 07:20 PM|LINK
I ran into the issue of if the user presses the "BACK" button, the page does not refresh. So I placed the meta tag in the header:
<meta http-equiv="CACHE-CONTROL" content="NO-CACHE" />
To attempt to resolve the issue. This fixed the issue for IE and other browsers. But firefox gave me a particular problem. They interpret this tag unlike the other browsers, thus not refreshing the page. After a bit of digging, I discovered this code: (Place
in the OnInit block, prefereably)
Note, this is new code as of 8-31-06
Response.AppendHeader("Cache-Control", "no-cache"); //HTTP 1.1
Response.AppendHeader("Cache-Control", "private"); // HTTP 1.1
Response.AppendHeader("Cache-Control", "no-store"); // HTTP 1.1
Response.AppendHeader("Cache-Control", "must-revalidate"); // HTTP 1.1
Response.AppendHeader("Cache-Control", "max-stale=0"); // HTTP 1.1
Response.AppendHeader("Cache-Control", "post-check=0"); // HTTP 1.1
Response.AppendHeader("Cache-Control", "pre-check=0"); // HTTP 1.1
Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.1
Response.AppendHeader("Keep-Alive", "timeout=3, max=993"); // HTTP 1.1
Response.AppendHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); // HTTP 1.1
Aug 05, 2006 06:56 AM|LINK
i've implement this code but not proper handle the browser expaire bucouse some page did handle but whne loggout form is handle ,
if have a any other solution thne plz send it.
Aug 31, 2006 07:03 PM|LINK
I have updated the code, the changes were not persisting the way i desired. New code below:
Sep 01, 2006 01:08 AM|LINK
Hello, afaik all you need to prevent output caching in asp.net is:
Sep 01, 2006 03:01 AM|LINK
Sep 01, 2006 04:51 AM|LINK
I might be wrong, but as far as i know and i've seen, that's just enough.
Maybe keep in mind that outputs an HTTP/1.1 compliant Cache-Control header, not the deprecated HTTP/1.0 Pragma: NoCache. Also, sending HTTP headers as META tags as you show above is furtherly deprecated and known to be unreliable, so that's maybe where your
original problems came from.
Check the help topic i've linked above for details and a reference to the official W3C documentation.
Hope i've not misinterpreted. -LV
Sep 01, 2006 06:56 PM|LINK
I took a few minutes to retest this out with just setting the page cachability. In firefox it still doesn't prevent caching.
This is mainly due to the way firefox caches pages in memory (which also leads to it gobbling up memory, the "memory bug")
So I reverted back to the code posted above.
Dec 05, 2006 06:15 AM|LINK
I had tried Response.Cache.SetCacheability(HttpCacheability.NoCache); it refreshes the page perfectly. but instead of refreshing the page, i want to display the "WebPage Expired" error page when the user clicks the back button. is it possible, if yes,
please give the solution to achieve this?
Thanks in advance
Dec 05, 2006 10:34 AM|LINK
Dec 05, 2006 12:38 PM|LINK
instead of refreshing the page, i want to display the "WebPage Expired" error page when the user clicks the back button. is it possible, if yes, please give the solution to achieve this?
I am afraid a simple and straight answer is: forget it. The main point is the web model is the web model, and you shouldn't be bothering at all about which button the user pressed to go to some page, because however s/he got there, that's just a page request.
So, disabling cache is something useful to force a page to be requested back to the server instead of being reloaded from the local cache. And, something you might need to add is some form of "idempotency", to prevent the same request to be processed twice
on the server. But you have not, and are not supposed to have any serious control over browser's workings, and after all the browser might be everything including a telnet against port 80 of your server. So no point in working-around it. Simply code your site
to "handle requests" and independent from the buttons users are pressing: back button, writing the url into the address bar, clicking a link or a bookmark, doesn't make any difference...
At least, that's my approach. -LV