Nginx environment PHP flush failure solution, nginxflush

Source: Internet
Author: User

Nginx environment PHP flush failure solution, nginxflush

Problem

When I debug PHP line-by-line output, I found thatOb_flushAndFlushBoth of them are invalid. You can use phpinfo to determine whether the php. ini settings are normal.

Solution

Check Nginx again and find that Nginx has the following settings:

Fastcgi_buffer_size 128 k; fastcgi_buffers 8 128 k;

The problem is basically found. Nginx will buffer the PHP output information and send the data in the buffer zone to the client only when it reaches K. Then we need to reduce the buffer zone first, for example:

Fastcgi_buffer_size 4 k; fastcgi_buffers 8 4 k;

In addition, gzip must be disabled.

Gzip off;

Then, in phpOb_flushAndFlushOutput a piece of content that reaches 4 K, for example:

Echo str_repeat ('', 1024*4 );

By now, PHP can passOb_flushAndFlushOutput the required content line by line.

Summary

The above is all about this article. I hope this article will help you in your study or work. If you have any questions, please leave a message.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.