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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

No caching of my page

Status
Not open for further replies.

msjfc615

Programmer
Feb 26, 2004
13
US
I am wondering the approiate code to use when I am trying to have my page not go back. I dont want the user to be able to go back to a page. For example the page gives the data from a form to be submited into the database then redirects the page to another page. I dont want the user to be able to go back to the page that accepts the data and redirects it. I setup a check to check the database but it was mentioned to me that it just uses the cached version of the page. So I guess my question what do I have to do so my page is not cached. Thanks in advance for your help
 
check out the header() function, I think theres a no-cache option.

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
I added :
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");

// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);

// HTTP/1.0
header("Pragma: no-cache");


and then I emptied my temp internet files, cleared my history, and cleared cookies. Then go through the process and when I hit the back button it still goes back however if I press reload on the page it tells me that I can not reaccess the page which is what I want it to say when the back button is pressed. Any suggestions on why the no cache calls are not working would be greatly appreciate them.
 
Depends on the browser. You can't control the back button in all browsers.
All that is stated in the RFC for no-cache content is that when the file is requested again it has to be loaded from the server. The developers of Opera for example read this literal: if the page is accessed using the back button it is not a request to the server, hence, a refresh is not needed.

Solution:
client side based timestamp evaluation. Have a hidden field that is populated with the timestamp of page generation. In the <body> tag have an onload event that checks if the timestamp is already set -> reload.
 
or you could supply a querystring with a random number, the browser ignores the cache then and always gets a fresh copy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top