I have a PHP script packaging some content together with zlib compression turned on, like so:
ini_set('zlib.output_compression', '1');
ini_set('zlib.output_compression_level', '-1');
And HTTP caching enabled like so:
$age = 60 * 60 * 24 * 365;
$expires = time() + $age;
header("Cache-control: max-age={$age}");
header('Pragma: cache'); // to overwrite Zend/PHP's default of `no-cache`
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', $expires));
This normally works fine. But, for one of my larger resources, my cache control headers are getting clobbered, and the following is being sent instead:
Cache-Control: no-store, no-cache, must-revalidate
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
This occurs in all tested server environments (CentOS/Apache, Raspbian/Apache, Windows/IIS) with a local network and localhost connections. Disabling the zlib compression brings the caching headers back; but, it's not a long-term solution.
What's causing zlib to break my caching headers on some resources? And, how do I ensure that it doesn't clobber my caching headers?