php flush() are not effective.

Ken Chen ken73.chen at gmail.com
Wed Apr 29 22:03:54 MSD 2009


hi Shri,

Thanks a lot! It works.

I change the nginx configuration to:

fastcgi_buffer_size 4k;
gzip  off;

And PHP script:

<?php

ob_flush();
echo The first line<br />";
flush();
sleep(2);

for ($i=10; $i>0; $i--)
{
    echo $i . "<br />";
    echo str_repeat(" ",4096);
    ob_flush();
    flush();
    sleep(1);
}
ob_end_flush();
?>

But how do you implement them to the productive server?

Set 'zlib.output_compression = On' in php.ini, and only compress static
content in nginx.conf ?


Regards,
Ken

2009/4/29 Shri @ DevLib.Org <shri at devlib.org>

>  I've noticed this too. Can you retry after turning gzip off? Worked in my
> case.
>
> We have some scripts which run for 20-30 mins, rebuilding some large
> databases and they need to be run isolated from the main webserver which has
> gzip on.
>
> Regards,
> Shri
>
>
> ----- Original Message -----
>  *From:* Ken Chen <ken73.chen at gmail.com>
> *To:* nginx at sysoev.ru
> *Sent:* Wednesday, April 29, 2009 11:20 PM
> *Subject:* php flush() are not effective.
>
> Hi all,
>
> I am trying to flush content before the end of PHP script. With below
> script, it works under lighttpd, but not work after changing to nginx.
>
> <?php
>
> ob_flush();
> echo "The first line<br />";
> flush();
> sleep(2);
>
> for ($i=10; $i>0; $i--)
> {
>     echo $i . "<br />";
> #    echo str_repeat(" ",8192);
>     ob_flush();
>     flush();
>     sleep(1);
> }
> ob_end_flush();
> ?>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20090430/2af7f8c0/attachment.html>


More information about the nginx mailing list