Php simply enables the gzip compression method (zlib. output_compression). generally, after gzip compression is enabled for a page file, its volume 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 tutorial on the Internet is based on two methods: copy me and copy him. In fact, code should be added to every php page ?? Of course, you can also include references, but it seems a little troublesome.
In fact, the simplest way is to open the php. ini file in the php Directory, find zlib. output_compression = Off, and change it to zlib. output_compression = On,
Remove the; zlib. output_compression_level; and change-1 to 1 ~ The value of 5. In this way, the gzip effect of all php pages can be achieved, without the need to modify the php file of the website separately ?? If there are many sites, it will save a lot of time.
Note the following points:
I. zlib. output_handler must be commented out because this parameter conflicts with the preceding settings ?? Official statement.
2. Generally, the cache is 4 k (output_buffering = 4096 ).
3. the recommended parameter value of zlib. output_compression_level is 1 ~ 5 or 6, the actual compression effect is not significant, but the cpu usage is a geometric increase.
. View the request header and response header through firebug. In fact, the gzip effect is displayed.