Jan 302014
 Posted by on January 30, 2014 at 6:54 am Apache Web Server, FAQ, Web Servers Tagged with: , ,  Add comments

To enable web compression, we need to create a mod_deflate.conf file and also do some changes to the web server configuration – httpd.conf file. Create mod_deflate.conf file with content provided below:

<Location />

SetOutputFilter DEFLATE

BrowserMatch ^Mozilla/4 gzip-only-text/html

BrowserMatch ^Mozilla/4\.0[678] no-gzip

BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Don't compress images

SetEnvIfNoCase Request_URI \

\.(?:gif|jpe?g|png)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content

Header append Vary User-Agent env=!dont-vary


Save and close mod_deflate.conf file and to modify the Web Server configuration file, open the file httpd.conf in the ‘<Apache_ROOT>/conf’ directory in a simple text editor

– Search for the following text and uncomment it.
#LoadModule headers_module modules/mod_headers.so

After uncommenting it should be

LoadModule headers_module modules/mod_headers.so

– Search for the following text and uncomment out it.
#LoadModule deflate_module modules/mod_deflate.so

After uncommenting it should be

LoadModule deflate_module modules/mod_deflate.so

– Include the mod_deflate.conf file in the HTTP server by adding the below line just after the Load Module section.
Include conf/mod_deflate.conf

– Save and close httpd.conf file.

To avoid double compression follow below steps.

– Cd to <Apache_ROOT>/conf
– Open mod_deflate.conf file using vi or notepad editor.
– Search for the following text:
SetOutputFilter DEFLATE
– Comment out the SetOutputFilter DEFLATE by simply using #. The final line should look like the the one below:
#SetOutputFilter DEFLATE
– Add the below directive in the config file.
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript
Note that above AddOutputFilterByType Directive compress only mentioned MIME types like text,jss,html,css,xml & Remaining all files will not be compressed.
– Restart the HTTP Server

© Incase of any copyright infringements please check copyrights page for faster resolutions.

Leave a Reply

Show Buttons
Hide Buttons