PHP Simple Open gzip compression method (zlib.output_compression) _php Tutorial

Source: Internet
Author: User
In general, after the paging file opens gzip compression, its volume can be reduced 60%~90%, for the text class site, can save a lot of bandwidth and user waiting time. However, both IIS and Apache only compress the HTML class static files by default, for PHP files need module configuration to support (iis7.5 in dynamic + static compression can also), so the use of PHP's own functions to achieve the effect of gzip has become a reasonable demand.

Online tutorial Basically you copy me to copy him, just add the head plus tail or two kinds of self-configuration function. Actually every PHP page is going to add code-and of course it can include references, but it's always a little cumbersome.

In fact the simplest way, open the PHP directory under the php.ini file, find zlib.output_compression = Off, change to zlib.output_compression = ON,

To Zlib.output_compression_level in front of, remove, and change the value of 1 in the back. This will enable the gzip effect of all PHP pages, no longer need to modify the site's PHP files separately-if the site is many, it will save a lot of time.

The following points need to be explained

The Zlib.output_handler must remain commented out, as this parameter conflicts with the previous setting-the official argument.

Second, in general, the cache is 4k (output_buffering = 4096).

Third, Zlib.output_compression_level recommended parameter value is 1~5,6 to the actual compression effect is not increased, CPU consumption is geometric growth.

Figure 1: Viewing the request header and the response header via Firebug, in effect the gzip effect has been shown

Figure 2. Webmaster Station gzip Detection Tool also shows that gzip is valid.

http://www.bkjia.com/PHPjc/326646.html www.bkjia.com true http://www.bkjia.com/PHPjc/326646.html techarticle in general, after the paging file opens gzip compression, its volume can be reduced 60%~90%, for the text class site, can save a lot of bandwidth and user waiting time. But whether it's IIS or ...

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