PHP to enable Zlib compressed file configuration method _php Tips

Source: Internet
Author: User
However, whether IIS or Apache by default only compressed HTML class static files, for PHP files need module configuration to support (iis7.5 in dynamic + static compression can also be), so the use of PHP itself to achieve gzip effect also become a reasonable demand.

The implementation of the method is very simple, open the PHP directory under the php.ini file,

Copy Code code as follows:

Zlib.output_compression = Off
; zlib.output_compression_level = -1output_buffering = Off

Modified into
Copy Code code as follows:

Zlib.output_compression =on
Zlib.output_compression_level = 5
Output_buffering = 4096


The following points need to be explained

The Zlib.output_handler must remain commented out because this parameter conflicts with the previous setting--an official claim.
Second, the general cache is 4k (output_buffering = 4096).
Third, the zlib.output_compression_level suggested that the parameter value is 1~5,6 above actual compression effect promotion is little, the CPU occupies is the geometrical growth.

Finally, the request headers and response headers are viewed through firebug, and the gzip effect has actually been displayed, or gzip is also displayed through the Webmaster gzip detection Tool.

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.