Something, I think Apache, adds these HTTP headers to all responses generated by PHP scripts:
Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
This works ok for actual dynamic pages, but I have some page that, while generated by PHP, are mostly static, and I want the browser to cache them.
Is there a way in PHP to remove those headers from the response, and thus activate the browser’s default caching rules, or if not, is there any value I can set them to that’s equivalent with them being absent?
I would prefer not to set my own values, because I want the browser to use the same caching rules as for static resources that are served by Apache itself (without using mod_cache).
Advertisement
Answer
First I’d check if it really isn’t one of the php scripts that sets these headers.
register_shutdown_function('foo');
echo "test";
function foo() {
flush();
$c = "headers_list: n " . join("n ", headers_list());
if ( function_exists('apache_response_headers') ) {
$c .= "napache_response_headers:";
foreach( apache_response_headers() as $k=>$v) {
$c.= "n $k=$v";
}
}
$c .= "nn";
echo '<pre>', $c, '</pre>';
}
Does this print something “usable” on your server?