Refresh PHP buffer to accelerate your site, refresh php buffer site _ PHP Tutorial

Source: Internet
Author: User
Refresh the PHP buffer to accelerate your site and refresh the php buffer site. Refresh the PHP buffer to accelerate your site. refresh the php buffer site. under the default configuration of the current PHP version, "OutputBuffering" is enabled. The old version does not refresh the PHP buffer to accelerate your site. refresh the php buffer site.

Under the default configuration of the current PHP version, "Output Buffering" is enabled. This is not the case with the old version. in the PHP version of the old version, each time the string is output (through the echo or print function), an action is triggered to send to the client browser.
The introduction of "output buffer" makes this process faster and more efficient. The buffer actually opens up a region in the memory and can be considered as a large string in the memory. When there are characters in the program to be output, the content to be output will be appended to the buffer, used to replace the previous version of PHP to directly output to the browser every time. When the buffer zone is refreshed, it is uniformly input to the user's browser. In the following situations,This will cause the "refresh" operation of the buffer zone:
1. PHP program execution is complete;
2. the cache size exceeds the output_buffering value set in the php. ini configuration file;
3. when the flush () or ob_flush () function is called.
In the actual product environment, we can refresh the PHP buffer immediately after the head tag to accelerate your site. the sample code is as follows:

   
  Buffer flushing in action 
  
  <? Php // force refresh the Buffer flush ();?>...

Next we will explain the role of the above code:
When the browser receives code from the head part of the page, it can start to download the resources included in the head segment, such as CSS files and site favorites icons (Favicon. The download of the content can be synchronized with the time when the browser accepts the content of the body segment.
The specific amount of acceleration needs to be tailored to local conditions. This depends on many objective conditions, including the server's response speed, your page size, your CSS file size and quantity, and whether the browser has a local cache. There are many factors, but such a small optimization can obviously accelerate your site. why not?

I hope you can use this tips on your website and track the actual results. We look forward to your feedback.

Under the default configuration of the current PHP version, "Output Buffering" is enabled. 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.