How does Apache enable Gzip compression? Gzip compression opening method

Source: Internet
Author: User


Before enabling Gzip, check whether the mod_deflate and mod_headers modules are loaded in the Apache configuration file.
The path to the Apache configuration file of the LAMP one-click installation script is/usr/local/apache/conf/httpd. conf.


Open this file and find the following two lines of code:

LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so

If there is no # symbol in front of it, it is normal. If there is # symbol, it indicates it has been commented out. Just delete the # symbol in front of it.

Add the following content at the end of the Apache configuration file/usr/local/apache/conf/httpd. conf:

<IfModule deflate_module>
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI .(? : Gif | jpe? G | png) $ no-gzip dont-vary
SetEnvIfNoCase Request_URI .(? : Exe | t? Gz | zip | bz2 | sit | rar) $ no-gzip dont-vary
SetEnvIfNoCase Request_URI .(? : Pdf | doc | avi | mov | mp3 | rm) $ no-gzip dont-vary
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>


Note:
IfModule deflate_module is used to determine whether the deflate_module is loaded and execute the configuration in it.
SetOutputFilter DEFLATE is the deflate compression algorithm.
SetEnvIfNoCase Request_URI is used to exclude some common image, audio, video, document, and other types of suffixes without compression.
AddOutputFilterByType DEFLATE compresses common text types, such as html, txt, xml, css, and js.

Save the modified configuration file and restart Apache.

Service httpd restart

Or

/Etc/init. d/httpd restart

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.