I have tried every combination and permutation of meta tags that are supposed to stop a page from being cached, but Firefox STILL caches the page! I just need the U
Why? I mean, why do you want to do this? When I press the back button, I want the standard function that the browser provides - to go back to the previous page. I don't want a suprise.
If it is to stop an accidental resubmission of a POST, that can be accomplished easily by ending the POST handling with a redirect to display the desired reply using a GET. A later back into this page, will redisplay the redirected GET (or reload it from the cache which must have the same result). This is what the user expects and is harmless.
This has the added advantage that if your save has failed when updating the database, the display will display what is on the database, not what has been left in the variables.
Check out live http headers, you'll see when you press the back button, no request is made. Which is done on purpose, so you don't loose what you may have typed into forms.
Edit
Some post on experts exchange said this worked, but its from 2006.
<META HTTP-EQUIV="Expires" CONTENT="0">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-store">
Then a javascript refresh
This works for me
make a new php file. I can use the back and forward buttons and the number on the page always updates
<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
echo time();
?><a href="http://google.com">aaaaaaaaaaaaa</a>
<meta http-equiv="Cache-Control" content="no-cache" />
I think the correct value is "no-cache"
You posted a comment:
It is because once the form has been submitted, IF the user presses the back button, the information they are viewing will be inaccurate.
If you want to prevent this you're doing it wrong! :)
What you need to do is a redirect when the form has been submitted.
<?php
// code that handles the form submit
header("Location: http://www.example.com/form-success.html"); // needs the absolute url (You can use $_SERVER['HTTP_HOST'], $_SERVER['PHP_SELF'] and dirname() for this)
exit; // prevents further execution of the php code when while doing to redirect
?>
You may add the following PHP Code in your PHP Page.
CodeIgniter Framework version:
$this->output->set_header('Last-Modified:'.gmdate('D, d M Y H:i:s').'GMT');
$this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate');
$this->output->set_header('Cache-Control: post-check=0, pre-check=0',false);
$this->output->set_header('Pragma: no-cache');
PHP version:
header('Last-Modified:'.gmdate('D, d M Y H:i:s').'GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0',false);
header('Pragma: no-cache');
And also you may add following Java Script Code in Login/Master Page at <head> Section:
<script language="javascript" type="text/javascript">
window.history.forward();
</script>
Compatibility verified in