Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to refresh page when press back button - why?

Status
Not open for further replies.

meeble3

Programmer
Nov 8, 2004
52
GB
Hello,

I have a page that pulls up records from the database. If you click a record for further information then click the back button on the browser, the page says:

"Warning: Page has Expired"

and you have to refresh the page.

Is there any way around this?

Cheers

James
__________________
 
It's probably your browser (most likely IE). Go into your internet options and clean out your temporary internet files. See if that cures the problem.
 
It's nothing to do with the browser. When you make a call to the database the page needs to be refreshed I think...
 
OK, if you say so.....
(did you actually try what I suggested?)
 
>>>>>>>>>>You have some form submitted on the previous page?

Yes that's right...

 
Probable you are using METHOD=POST, in the form.
So, the server asks you to submit again the parameters.
If is not a problem for you, you can tray with METHOD=GET






___
____
 
are you using any sessions by chance???

Known is handfull, Unknown is worldfull
 
The reason is because you're using the POST method to submit the form. That's why you get the warning. Because in order to show the page again, it would have to re-POST the data. The same thing would happen if you submitted the page, then pressed refresh/reload (even without clicking a record).

A solution might be to use GET instead of POST (if the query is pretty simple and it's OK to put the data in the URL) or alternatively, when the user click's the link for more information, have it open in a new window. Or if you're afraid of that being blocked by SP2 as a pop-up, have it create a div with an IFRAME as the source.

Hope this is of some help
 
sorry predamarcel, i think we both posted at the same time !!
 
This actually is the browser.

The browser can be setup to do nothing but reload the cached version it had just displayed, to resubmit the form it had submitted last time, or to just crap out.

Rather than saying it has nothing to do with the browser, go ahead and prove it to yourself by loading the same page in Firefox... you will get similar, yet different behavior.
 
Hi
I had the same problem and did the following:

Place this code at the top of your php file.

Code:
header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: post-check=0, pre-check=0",false);
session_cache_limiter("must-revalidate");

 
That looks pretty nifty Andy, I'm pretty new to PHP, would you mind explaining what it does?????
 
I havent tested this, but if it's logic, this is what it looks like to me:

1: Set expires to NEVER (though, why 2000?):
header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
2: Set modified to NOW (fake that the post is new?):
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
3: Force the client to not check for post:
header("Cache-Control: post-check=0, pre-check=0",false);
4: Force session cache to revalidate
session_cache_limiter("must-revalidate");

I might be mistaken here, but that's what I think it does.
When I think back on ASP, I remember that you could modify the EXPIRES to make it not cache pages. Though, I think it involved some negative values. I might be mistaken here though, as I did not program in ASP for some years.

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top