I'm writing a server sent event stream in PHP and I receive the error:
"failed to flush buffer zlib output compression"
This I believe is due to trying to flush the gzipped output.
Here's my PHP code:
header ("Content-Type: text/event-stream\n\n");
header ("Cache-Control: no-cache");
echo "data: {$json}";
echo "\n\n";
ob_flush(); // ERROR HERE
flush();
My question is what is the best way to get this working - ideally without disabling gzip in apache - can it be turned off in PHP?
I tried this but it didn't work:
if(ini_get('zlib.output_compression')){
ini_set('zlib.output_compression', 'Off');
}