Refresh the PHP buffer for your site to accelerate _php tips

Source: Internet
Author: User

In the current PHP version of the default configuration, "Output buffer (buffering)" is opened. This is not the case in older versions of PHP, where strings are emitted every time it is output (via the Echo or print function), triggering an action sent to the client browser at a time.
The introduction of "Output buffering" makes the process faster and more efficient. The buffer actually opens up an area in memory and can be thought of as a large string in memory. When a program has characters to output, the content to be output is appended to the buffer to replace the old version of PHP, which is directly exported to the browser each time. When the buffer is "refreshed", it is then unified into the user's browser. The following situations cause a "refresh" operation on the buffer:
1, PHP program execution completed;
2. The buffer size exceeds the output_buffering value set in the php.ini configuration file;
3, flush () or the Ob_flush () function is called.
in the actual product environment, we can speed up your site by refreshing the PHP buffer immediately after the head tag, the sample code is as follows:

<! DOCTYPE html> 
 
 

Next, explain the effect of this code:
when the browser receives the code in the Head section of the page, you can start downloading the resources included in the head section, like CSS files, site Favorites icons (Favicon), and so on. These downloads can be synchronized with the time the browser accepts the contents of the body section.
Concrete can accelerate how much, need to local conditions. This depends on a number of objective conditions, including the response speed of the server, your page size, the size and number of your CSS files, whether your browser has a local cache, and so on. There are many factors, but such a small optimization, it can be obvious for your site acceleration, why not?

I really want you to use this tip on your website and keep track of the actual results. We look forward to your feedback.

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.