This is what the PHP docs say about the zlib.output_compression INI directive:
Whether to transparently compress pages. If this option is set to “On” in php.ini or the Apache configuration, pages are compressed if the browser sends an “Accept-Encoding: gzip” or “deflate” header. “Content-Encoding: gzip” (respectively “deflate”) and “Vary: Accept-Encoding” headers are added to the output. In runtime, it can be set only before sending any output.
Seems pretty straightforward, except that enabling this directive on an openSUSE 10.3 server (and an openSUSE 10.2 server) resulted in a bunch of gibberish as output. Meanwhile, the compression worked just fine on my MacPorts-enhanced MacBook.
After flailing around on Google and php.ini, I eventually eliminated SSL and the firewall as reasons for the problem. During this process I wasted a good amount of time on this bug. Basically, the docs say that you can set zlib.output_compression in your script at runtime, but in reality it doesn’t work.
I finally got down to business with Live HTTP Headers and figured out that enabling zlib compression on my openSUSE servers certainly compressed the content, but did not send the requisite “Content-Encoding: gzip” response header. Sending the header manually within my script (e.g.
header("Content-Encoding: gzip");) would correctly turn the gibberish into uncompressed form.
Having already spent hours mucking around with this, I went with a quick and dirty solution:
I hunted around Google for this problem, but only found PHP4 references from years ago. Maybe it’s time to ditch openSUSE on my servers… Ubuntu LTS might hit the spot.