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