PHP implementation Bigpipe block output

Source: Internet
Author: User

Principle: Using Ob_flush () and flush () to output the contents of the buffer ahead of time, the browser can load this part of the content early, without waiting for all the output to complete and then load.

The content of the page is divided into small pieces, output one and then output the next, so that users can see the content of the page as soon as possible, optimize the user experience.

First the contents of the head should be loaded, load css,javascript and other static content as soon as possible, so you should use flush () output after head.

Example: First output head static content, then each <p> is divided into a chunk, every second output.

<!  
 DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >  

The issues to be noted:

1. Try to use as much content as possible once output.

2. Try to load synchronously.

3.chunk is not the more the better, depends on the actual needs of the decision.

4.ob_flush () and flush () should be used at the same time, because in some cases flush () will have no effect.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/PHP/

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.