PHP Output buffer flush issue on Apache/Linux

Posted by Iiro Vaahtojärvi on Server Fault See other posts from Server Fault or by Iiro Vaahtojärvi
Published on 2010-05-03T11:58:08Z Indexed on 2010/05/03 11:59 UTC
Read the original article Hit count: 349

Filed under:
|
|
|

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!

© Server Fault or respective owner

Related posts about apache

Related posts about php