Use. htaccess to enable gzip compression on the CentOS server

Source: Internet
Author: User
Tags centos server
The effect of Gzip compression on the loading time of the webpage is still great. The data transmission volume of the webpage after Gzip compression is generally reduced by more than 70% than that before compression. Therefore, many PHP programs enable Gzip compression to save traffic and speed up page loading. There are many ways to enable Gzip compression for web pages. for my independent server, it is better to enable corresponding options directly in php. ini. However, if you have enabled Gzip in all running PHP programs

The effect of Gzip compression on the loading time of the webpage is still great. The data transmission volume of the webpage after Gzip compression is generally reduced by more than 70% than that before compression. Therefore, many PHP programs enable Gzip compression to save traffic and speed up page loading.

There are many ways to enable Gzip compression for web pages. for my independent server, it is better to enable corresponding options directly in php. ini. However, if you do this, you have to disable the Gzip option in all running PHP programs. Otherwise, an error is reported.

I didn't want to bother with those settings, so I found a method to use. htaccess to control a single website to enable Gzip output.

The method is simple.Under the root directory of the website, Create a. htaccess file (edit it if it has been created). enter the following line of code in any row of the file and save the code to enable the Gzip output of the corresponding website:

Php_value output_handler ob_gzhandler

How is it? It's easy. after such a small change, the access speed to your website will be much faster, and the traffic transmission will be saved.

  • Previous article: Let Ubuntu Server use wireless
Related Article

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.