Home  >  Article  >  Backend Development  >  What are the benefits of turning on gzip? How to determine whether the server supports gzip compression in php

What are the benefits of turning on gzip? How to determine whether the server supports gzip compression in php

奋力向前
奋力向前forward
2021-07-07 10:08:112320browse

What are the benefits of opening GZIP? The Gzip function is a way to compress the size of web pages to speed up the speed of opening web pages. Almost all current mainstream browsers support this function. Friends who are interested in how PHP knows whether the server supports Gzip compression can participate

What are the benefits of turning on gzip? How to determine whether the server supports gzip compression in php

This is a very practical and popular function, but turning on Gzip is If you need server support, how do you know whether the server where your site is located supports the Gzip compression function? Ask your space service provider directly? Of course, but is there any other way besides this? Of course there is, and here is a method introduced from a technical perspective.

Create a new php type file, which can be named test.php. Write the following code in the file:

/**
 * php如何知道服务器是否支持Gzip压缩
 *
 * @param 
 * @arrange : php-中文网:php.cn
 **/
<?php phpinfo(); ?>
/***   来自php中文网(www.php.cn)   ***/

Then save and upload it to the root directory of the space you need to test. After uploading, open the URL of this file in the browser:
http://your domain name and directory/test.php

After opening the page, CTRL F searches for the following string:

_SERVER["HTTP_ACCEPT_ENCODING"]

After finding it, check whether there is a gzip parameter at the back. If so, congratulations, your space supports Gzip. If not, unfortunately, it means that your website cannot be compressed by Gzip.

Recommended learning: php video tutorial

The above is the detailed content of What are the benefits of turning on gzip? How to determine whether the server supports gzip compression in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:512pic.com. If there is any infringement, please contact admin@php.cn delete