Nginx solution at ambient PHP flush failure

Recently found in the work of a question, PHP is actually flush fails, from the Internet to find some information was found to be the cause of Nginx, so this article is to introduce the problems and solutions, there is a need friends to below a look at it.
problem

I am a progressive output debugging PHP, I found ob_flush and flush both fail, through phpinfo php.ini settings can basically judge is normal.

Solution

Then go Nginx, Nginx found in the following settings:

fastcgi_buffer_size 128k; fastcgi_buffers 8 128k;
basic problem found, Nginx will buffer information PHP output only when it reaches 128k will buffer the data sent to the client, we first need to buffer this little tune, such as: birthday character from the name

fastcgi_buffer_size 4k; fastcgi_buffers 8 4k;
and must be disabled gzip

gzip off;
then, in php, and before the flush ob_flush, 4k content reaches the output section, for example:

echo str_repeat ( '', 1024 * 4);
this, PHP can properly flush the content and progressive output ob_flush need.

to sum up

That's all for this article, I hope the contents of this paper, we study or work can bring some help, if in doubt you can leave a message exchange.

Guess you like

Origin blog.csdn.net/sakura379/article/details/93471574