Firefox seems to save the whole page state including values of javascript variables and DOM and restoring it when user hits back button. How to prevent this behaviour?
Cache on server side prevented:
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache,no-store,private,must-revalidate,max-stale=0,post-check=0,pre-check=0");
header("Pragma: no-cache");
All forms on page have autocomplete='off'
, all hidden input elements have it too.
onload
event is not fired.
Is there any way to tell Firefox totally forget page state after form submission? setting timeout in onsbumit handler which will force page reload is a bad idea, because next page can react in unpredictable time. In case of long response reload will break the request.
How to reproduce:
<body>
<form method='POST' action='http://httpbin.org/post' autocomplete='off'>
<input type='text' placeholder='Enter something' name='data' autocomplete='off'/>
<input type='hidden' name='token' value='and_token_field_that_must_not_be_cached' autocomplete='off'/>
<input type='submit' />
</form>
<span id='counter'></span>
<script>
var tick = 0;
setInterval(function () {
document.getElementById('counter').innerHTML = tick ++;
}, 300);
</script>
</body>
Wait a bit, press submit, then back. FF will display the same counter value as before page submission, Chrome will reset it.