How to configure zlib Compressed Files in php _ PHP Tutorial

Source: Internet
Author: User
Php enables the zlib Compressed file configuration method. However, both iis and apache only compress html static files by default. for PHP files, the module configuration is required. (dynamic and static compression can be enabled in iis7.5 ), therefore, p is used, but by default, html static files are compressed both in iis and apache. This function is supported only when the module configuration is required for PHP files (dynamic and static compression can be enabled in iis7.5 ), therefore, the effect of using php's own functions to reach gzip has become a reasonable demand.

The implementation method is very simple. open the php. ini file under the php Directory,

The code is as follows:


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


Modify

The code is as follows:


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



Note the following points:

I. zlib. output_handler must be commented out because this parameter conflicts with the previous settings-the official statement.
2. Generally, the cache is 4 k (output_buffering = 4096 ).
3. the recommended parameter value of zlib. output_compression_level is 1 ~ The actual compression effect is not significant, but the cpu usage is a geometric increase.

Finally, you can view the request header and response header through firebug. In fact, the gzip effect is displayed, or the gzip check tool of the webmaster also shows that gzip is valid.

By default, ghost and apache only compress html static files. for PHP files, the module configuration is required (dynamic + static compression can be enabled in iis7.5). Therefore, p...

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.