eatc7402 Posted May 24, 2007 Share Posted May 24, 2007 I have an html page that gets updated about once a week. I would like to FORCE the browser (IE, Firefox, Netscape, or Opera) to REFRESH when the user opens the page to ensure they receive the latest update. Been searching around for some php code to add to the page to accomplish this without success. Can anyone give me a steer to how to accomplish this. Thanks. Dave, eatc7402 Quote Link to comment Share on other sites More sharing options...
Wildbug Posted May 24, 2007 Share Posted May 24, 2007 http://us.php.net/header PgDn about once. Quote Link to comment Share on other sites More sharing options...
eatc7402 Posted May 24, 2007 Author Share Posted May 24, 2007 I am sorry, but I don't understand what you are telling me. What does PgDn have to do with REFRESH?? eatc7402 Quote Link to comment Share on other sites More sharing options...
per1os Posted May 24, 2007 Share Posted May 24, 2007 <?php header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past ?> Is what he was referring to. As to making the browser refresh, without javascript or some type of a time function it is really not possible. If you want a refresh after a certain amount of time Javascript is what you want. Quote Link to comment Share on other sites More sharing options...
corbin Posted May 24, 2007 Share Posted May 24, 2007 PHP could refresh with a header request to the same page, but that would be pointless since it would be processed before the script, thus sending you into an infinite loop (unless you flagged some variable, but I don't see a use behind that). Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 25, 2007 Share Posted May 25, 2007 simple HTML <?php echo "<meta http-equiv='refresh' content='5;http://mydomain.com/page1.php'>"; ?> change 5 to the number of seconds Quote Link to comment Share on other sites More sharing options...
eatc7402 Posted May 25, 2007 Author Share Posted May 25, 2007 Well this ALMOST seems to work. If I force the page to go to a DIFFERENT url than the one I'm already on, it works. But, I don't want to go to another page, I simply want to force a REFRESH of the one I'm already on. So, turning the new url into the page I'm already on causes a LOOP of refreshes that continues forever. I tried to add an exit statement but that did not seem to fix it. Also somethings wrong with the syntax, as I see a "; ?> on the screen which are the last 5 characters of the echo command not being properly recognized. Hummm. eatc7402 Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 25, 2007 Share Posted May 25, 2007 this works fine simple HTML <?php echo "<meta http-equiv='refresh' content='5;http://mydomain.com/page1.php'>"; ?> change 5 to the number of seconds what exactly are you trying to do ? heres how i used it (as part of a download script) <?php if( isset($_GET['DL']) ) { //download }else{ echo "please wait..."; echo "<meta http-equiv='refresh' content='5;{$_SERVER['REQUEST_URI']}?DL=1'>"; } ?> Quote Link to comment Share on other sites More sharing options...
eatc7402 Posted May 25, 2007 Author Share Posted May 25, 2007 What exactly am I trying to do?? I want to find a way to ensure that even if the user has the html page chache turned ON, that they will get a REFRESHED copy of a particular html page EACH time they view it, so they do not MISS updates. eatc7402 Quote Link to comment Share on other sites More sharing options...
yzerman Posted May 25, 2007 Share Posted May 25, 2007 http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html Read 14.9 - 14.9.6 I believe this is what you are after Quote Link to comment Share on other sites More sharing options...
per1os Posted May 25, 2007 Share Posted May 25, 2007 <?php header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past ?> Is what he was referring to. As to making the browser refresh, without javascript or some type of a time function it is really not possible. If you want a refresh after a certain amount of time Javascript is what you want. What is wrong with this code? If that is set on the page anytime a user refreshes the page it revalidates it. Now if you want to send a signal when you do an update to every page a user is on to refresh, that would require AJAX. I would suggest googling AJAX for how to do that. Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 26, 2007 Share Posted May 26, 2007 I agree with frost but if its a pure HTML page then try this <HTML> <HEAD> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Expires" CONTENT="-1"> </HEAD> <BODY> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.