Problem with return using flush () in php

0

It's my first post here on the site. I have a problem that I do not know how to solve. I do not know if it is a limitation of my server ...

I would like this code below to return one number after another within a second, but on my server the page goes blank and when it all comes it all at once. On the other server it works as I want.

echo 'Begin ...<br />';
for( $i = 0 ; $i < 10 ; $i++ )
{
    echo $i . '<br />';
    flush();
    ob_flush();
    sleep(1);
}
echo 'End ...<br />';

I recorded a video explaining the problem.

Youtube

On this server it works like I wanted it to: link

In this, what I need does not work : link

Use NGINX on a LINODE server instance with 1GB of RAM and 1 core. Is that it? Server Limitation?

    
asked by anonymous 09.03.2018 / 01:53

1 answer

1

The likely cause is the NGINX output buffer.

You can, disable the proxy in the configuration file:

proxy_buffering off;

Or try to disable via reader in your code:

header('X-Accel-Buffering: no');

Reference: link

    
09.03.2018 / 02:30