User Contributed Notes 2 notes

Apparently, there is a bug in certain versions of PHP with setting zlib.output_compression to "On" via ini_set:

<?phpini_set("zlib.output_compression", "On");?>

In some cases, it does not send the Content-type header and browsers won't know to decompress the contents before displaying. Instead, you can set it to the buffer size, which sends the correct header:

In the hopes this will help others - a hard to spot gotcha when implementing zlib.output_compression. if you use flush() anywhere in your script (even right at the end) the compression won't work - you need to let that happen automatically or it ends up being sent uncompressed.