2 ways to turn on gzip compression in PHP, Phpgzip 2 types of compression
After the Web page opens gzip compression, its volume can reduce 20%~90%, can save a lot of bandwidth, thus reduce the page response time, improve the user experience.
PHP Configuration Modification Method:
Copy the Code code as follows:
Zlib.output_compression = On
; Turn on the gzip feature
Zlib.output_compression_level = 4
; gzip compression level, 1~9, recommended
; Zlib.output_handler =
; Gzip compression method, recommended note
PHP File Modification Method:
It is recommended to write at the beginning of the page, can write to the head public file
Copy the Code code as follows:
if (!headers_sent () &&//If the page header information is not output
extension_loaded ("zlib") &&//and PHP has loaded the zlib extension
Strstr ($_server["http_accept_encoding"], "gzip")//and the browser accepts gzip
{
Ini_set (' zlib.output_compression ', ' on ');
Ini_set (' Zlib.output_compression_level ', ' 4 ');
}
http://www.bkjia.com/PHPjc/951231.html www.bkjia.com true http://www.bkjia.com/PHPjc/951231.html techarticle PHP in 2 ways to open gzip compression, Phpgzip compression 2 kinds of Web pages to open gzip compression, its volume can be reduced 20%~90%, can save a lot of bandwidth, thereby reducing the page response time, ...