Generally, after gzip compression is enabled for a page file, the size of the page file can be reduced by 60% ~ 90%. For text sites, you can save a lot of bandwidth and user waiting time. However, by default, both iis and apache only compress html static files. For PHP files, the module configuration is required. (Dynamic and Static Compression can be enabled in iis7.5 .)
Generally, after gzip compression is enabled for a page file, the size of the page file can be reduced by 60% ~ 90%. For text sites, you can save a lot of bandwidth and user waiting time. However, by default, both iis and apache only compress html static files. For PHP files, the module configuration is required. (Dynamic and Static Compression can be enabled in iis7.5 .)
Generally, after gzip compression is enabled for a page file, the size of the page file can be reduced by 60% ~ 90%. For text sites, you can save a lot of bandwidth and user waiting time. 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, 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,
zlib.output_compression = Off;zlib.output_compression_level = -1
output_buffering = Off
Modify
zlib.output_compression =Onzlib.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.