Page 1 of 1

forcing cached pages to reload in php

Posted: Fri Feb 06, 2004 1:50 pm
by Burrito
I'm new to php so forgive me if this is a dumb question. I'm devloping a site and a lot of my dynamic pages require me to refresh them for the new info to show up. Is there a way that I can force them to refresh when the user hits the page no matter what?

thx,

Burr

Posted: Fri Feb 06, 2004 1:54 pm
by Michael 01
There is a refresh command in Java that allows you do such a thing. They are a dime a dozen on the net, and actually most HTML editors have them included in their script vocabulary.

Posted: Fri Feb 06, 2004 1:57 pm
by Burrito
well I"m not interested in having the page load, then reload which is all that JS will give me. I would like to have the server feed them the new information right off the bat every time they hit it.

any other ideas?

burr

Posted: Fri Feb 06, 2004 2:24 pm
by Saethyr
straight out of the PHP manual:

PHP scripts often generate dynamic content that must not be cached by the client browser or any proxy caches between the server and the client browser. Many proxies and clients can be forced to disable caching with

Code: Select all

<?php
// 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");
?>
Note: You may find that your pages aren't cached even if you don't output all of the headers above. There are a number of options that users may be able to set for their browser that change its default caching behavior. By sending the headers above, you should override any settings that may otherwise cause the output of your script to be cached.

Additionally, session_cache_limiter() and the session.cache_limiter configuration setting can be used to automatically generate the correct caching-related headers when sessions are being used.

Saethyr

done

Posted: Fri Feb 06, 2004 3:07 pm
by Burrito
Muchos..

Burr

Posted: Fri Feb 06, 2004 3:57 pm
by Saethyr
de nada.


Saethyr