2 ways to turn on gzip compression in PHP, Phpgzip compress 2 _php Tutorials

Source: Internet
Author: User

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, ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.