Php nginx is a simple implementation method for real-time output.

Source: Internet
Author: User

Php nginx is a simple implementation method for real-time output.

The method for enabling real-time output in PHP is ob_implicit_flush (),

However, it does not work in most cases,

In the php. ini configuration, most output_buffering output buffering is enabled On,

Zlib. output_compression is also frequently enabled,

In addition to the PHP layer, Nginx buffer settings proxy_buffering and gzip compression are also enabled.

For the sake of one or two pages, I am afraid no one will make this choice to modify the website configuration of the entire server.

Here we recommend a simple method:

Set_time_limit (0); ob_end_clean (); ob_implicit_flush (); header ('x-Accel-Buffering: no'); // the key is to add this line. Echo 'here is :'. date ('H: I: s '). '<br>'; sleep (5); echo 'after five seconds :'. date ('H: I: s ');

Summary

The above is a simple implementation method of php nginx real-time output introduced by xiaobian. I hope it will be helpful to you. If you have any questions, please leave a message and I will reply to you in time!

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.