Php simply enables the gzip compression method (zlib. output_compression ). 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, for iis, after gzip compression is enabled for page files, the size of the page files 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, it can also be referenced by include, but it always 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 files 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 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 ~ 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.
The gzip detection tool of the webmaster site also shows that gzip is valid.
Bytes ~ 90%. for text sites, you can save a lot of bandwidth and user waiting time. However, whether it is iis or...