Home > Backend Development > PHP Tutorial > Configuration method to enable zlib compressed files in php_PHP tutorial

Configuration method to enable zlib compressed files in php_PHP tutorial

WBOY
Release: 2016-07-21 15:07:03
Original
1020 people have browsed it

However, both iis and apache only compress HTML static files by default. PHP files require module configuration to support them (dynamic + static compression can also be enabled in iis7.5), so the effect of using PHP's own functions to achieve gzip has also become a a reasonable request.

The implementation method is very simple, open the php.ini file in the php directory,

Copy the code The code is as follows:

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

Modify to
Copy code The code is as follows:

zlib.output_compression =On
zlib.output_compression_level = 5
output_buffering = 4096


Need explanation The following are the following points

1. ;zlib.output_handler must remain commented out because this parameter conflicts with the previous setting - the official statement.
2. Generally, the cache is 4k (output_buffering = 4096).
3. The recommended parameter value for zlib.output_compression_level is 1~5. Above 6, the actual compression effect will not improve much, but the CPU usage will increase geometrically.

Finally, check the request header and response header through firebug. In fact, the gzip effect has been displayed, or the webmaster's gzip detection tool also shows that gzip is effective.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327580.htmlTechArticleHowever, both iis and apache only compress html static files by default. PHP files require module configuration to support them. (You can also enable dynamic + static compression in iis7.5), so use p...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template