Refresh PHP buffer for your site acceleration, refresh PHP buffer site _php Tutorial

Source: Internet
Author: User

Refresh the PHP buffer for your site acceleration, refresh the PHP buffer site


In the current PHP version of the default configuration, "Output buffering" is opened. The old version is not so, in the old version of PHP, the string at each time the output (through the Echo or print function), will trigger a send to the client browser action.
The introduction of "Output buffering" makes this process faster and more efficient. A buffer is actually an area in memory that can be thought of as a large string in memory. When there are characters to output in the program, the content to be output is appended to the buffer, which is used to replace the previous version of PHP directly output to the browser each time. When the buffer is "refreshed", it is then uniformly entered into the user's browser. The following scenarios cause a "refresh" operation of the buffer:
1, the implementation of the PHP program completed;
2, the size of the buffer exceeds the Output_buffering value set in the php.ini configuration file;
3. The flush () or 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:

   
 
  Buffer Flushing in action 
 
   
 
    <?php//Force flush Buffer Flush () here;?>  

The next step is to explain the effect of the above code:
When the browser receives the code from the Head section of the page, it can start downloading the resources included in the head section, such as the CSS file, the site collection icon (Favicon), and so on. The download of these contents can be synchronized with the time when the browser accepts the contents of the body segment.
How much can accelerate, need to adapt to local conditions. This depends on many objective conditions, including the response speed of the server, your page size, your CSS file size and number, whether the 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 very much hope that you will use this little technique on your website and follow the actual results. We look forward to your feedback.

http://www.bkjia.com/PHPjc/1060096.html www.bkjia.com true http://www.bkjia.com/PHPjc/1060096.html techarticle Refresh the PHP buffer for your site acceleration, refresh the PHP buffer site in the current PHP version of the default configuration, "Output buffering" is opened. The old version is not ...

  • 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.