views:

43

answers:

1

Hello I want to refresh a script from the server when back button is pressed. For that, i'm using this code:

header( "Last-Modified: " . gmdate( "D, j M Y H:i:s" ) . " GMT" ); 
header( "Expires: " . gmdate( "D, j M Y H:i:s", time() ) . " GMT" ); 
header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1 
header( "Cache-Control: post-check=0, pre-check=0", FALSE ); 
header( "Pragma: no-cache" ); // HTTP/1.0

But it seems the browsers (IE 8, FF 3.6) are still "caching" the page. Any help will be appreciated.

+2  A: 

I'm convinced you can't actually control it. The backbutton it something entirely diffent from a new request, up to the user-agent (in most contexts a browser like MSIE, FF, Chrome, Safari, Opera and the like), and most likely they all have their own interpretation about what the end user wants when pressing the back button. In a lot of cases, there's not even a HTTP request involved, and the DOM is loaded as it was before navigating away. This includes any alterations done client-sided.

In short: influencing and hinting by the code you already have is about the best you can do. To get a 'fresh' page the user has to reload it (pushing F5 in most instances). You could add ad meta refresh on your page to try to make the page as current as possible in user-agents that allow it.

Wrikken
Thanks for your answer, i think i gonna put a message saying, "you may need to refresh the page for the changes to take effect"....
jartaud