How to enable gzip compression in apache

Source: Internet
Author: User

Apache is easy to enable the gzip compression function.

The following lines are found in http. conf. If not, add

The code is as follows: Copy code

LoadModule deflate_module modules/mod_deflate.so

Restart.

We recommend that you enable both of them. The mod_expires.so module is used to set the webpage expiration time.

The code is as follows: Copy code
LoadModule deflate_module modules/mod_deflate.so
LoadModule expires_module modules/mod_expires.so

About compression and Expiration Time. Typical code:

Create. htaccess in the directory of your website and add the following content:

The code is as follows: Copy code

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/png A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType application/x-javascript A604800
ExpiresByType text/css A604800
</IfModule>

Compress all website text

The code is as follows: Copy code

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xhtml + xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/rss + xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE image/svg + xml
</IfModule>

The image is compressed at a high level. Therefore, compression is meaningless,

It is not cost-effective from the beginning, because it is cost-effective for us to compress the text.

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.