PHP Output buffer flush issue on Apache/Linux
- by Iiro Vaahtojärvi
Hi,
I'm running into issues with the PHP output buffer flushing on my Linux web server. The output buffer is maintained correctly and all the right data is pushed to it in my code, but the usual flushing mechanisms won't flush it to the browser. I have tried everything posted here: http://php.net/manual/en/function.flush.php but no success so far.
I got a small script from php.net to test it:
<?php
ob_start();
for($i=0;$i<70;$i++)
{
echo 'printing...<br />';
ob_get_flush();
flush();
usleep(300000);
}
?>
This should print "printing..." to the browser 70 times, one line every three seconds. This works fine on my other testing environment which is based on Windows (still using apache, XAMPP package), but on my Linux server it doesn't. It waits for the script to finish before giving anything to the browser, basically ignoring the whole flush command.
If anyone has experienced this before or knows of anything that could help (be it server configuration or adjustment to code) it would be greatly appreciated!