Home  >  Article  >  Backend Development  >  Gzip compression transmission method in HTTP mode in PHP_PHP tutorial

Gzip compression transmission method in HTTP mode in PHP_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:57:09881browse

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/317904.htmlTechArticleGzip 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...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn