Cannot overwrite Cache-Control in PHP
I've moved a older site to a new server, and the client has found a very odd behaviour.
Very close to the end, I have this code:
if (!$this->cache) {
header('Expires: '.gmdate('d M Y H:i:s', 946684800).' GMT');
header('Cache-Control: no-cache');
header('Pragma: no-cache');
}
Now the odd thing is the Cache-Control line doesnt work. After packet sniffing I see this:
Expires: 01 Jan 2000 00:00:00 GMT
Cache-Control: max-age=300, public
Pragma: no-cache
The order of the headers is exactly how I set them, but the Cache-Control is c开发者_开发知识库ompletely different. I've grepped my code for any mention of cache-control and there is only that mention, and another one designed to force caching in a different file but it is a different line to what I'm seeing so it cant be the culprit.
Does anyone know why Cache-Control is changing?
If you are using sessions, it's possible that PHP is overwriting them. Take a look at session_cache_limiter()
in the manual.
Alternatively, you can try setting those headers after you call session_start()
.
(Edit: I missed the bit about "Very close to the end," so maybe this isn't your problem.)
I think you are running Squid, you should check its config for:
header_replace Cache-Control max-age=300, public
精彩评论