Home > Article > Backend Development > Gzip compression transmission method in HTTP mode in PHP_PHP tutorial
Gzip compression transmission can more effectively save bandwidth traffic. He first compresses the text into .gz and then transmits it to the browser. Finally, the browser is responsible for decompressing and presenting it to the user.
Older versions of browsers may not be able to display it, but most browsers now can.
Enabling Gzip transmission first requires PHP 4.0.5 or later.
Method 1:
Add
php_flag zlib.output_compression on
php_value zlib.output_compression_level2 in .htaccess
Method 2 :
Add
ob_start("ob_gzhandler");
to the top of the php head. Both methods can achieve the effect of compressed transmission.
Check here whether your website is compressed
How to GZIP compress HTML?
This is very simple: first make the HTML into PHP, and then rewrite the html in .htaccess.