Admins eHow SysAdmin Tips & Tricks

May 11, 2014

How to enable mod_deflate on Apache 2.4

Filed under: Apache — Tags: , , , — admin @ 7:02 am

Well, I am writing this guide because enabling mod_deflate on Apache 2.4 has become more complex than enabling a single module like it was on Apache 2.2
Now you have to enable 3 modules in httpd.conf for mod_deflate to work properly :

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

Also you have to enable compression by this config :

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
DeflateCompressionLevel 9

September 5, 2012

How to verify mod_deflate, gzip working ?

Filed under: Apache — Tags: , , , — admin @ 12:42 pm

Lets say you have enabled compression in your web server by mod_deflate, gzip and now want to verify if the content is really compressed, here is how to do it :

1.Easy way :
Go to this link : http://www.gidnetwork.com/tools/gzip-test.php
Enter your website URL inside “Web Page URL” and click on “Check”

2.Technical way :
Make sure curl is installed on your server. then run following command (change yoursite.com to your own domain) :

curl -I -H 'Accept-Encoding: gzip,deflate' http://yoursite.com

what you should look for in output is this line :

Content-Encoding: gzip

if it is not there, the content is not compressed.
here is the output for AdminseHow :

root@x~# curl -I -H 'Accept-Encoding: gzip,deflate' http://www.adminsehow.com

HTTP/1.1 406 Not Acceptable
Server: ApacheBooster/1.3
Date: Wed, 05 Sep 2012 12:39:22 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 8740
Connection: keep-alive
X-Pingback: http://www.adminsehow.com/xmlrpc.php
Vary: Accept-Encoding,Cookie,User-Agent
X-Powered-By: W3 Total Cache/0.9.2.4
Content-Encoding: gzip
Last-Modified: Wed, 05 Sep 2012 12:39:22 GMT
X-Cacheable: YES
Accept-Ranges: bytes
X-Varnish: 1984902025
Via: 1.1 varnish
age: 0
X-Cache: MISS

The content is compressed. YAY 😀
PS : I know the response is “HTTP/1.1 406 Not Acceptable”, it is because of mod_security installed on server which prevents such simple automated requests to be served. but it doesn’t matter for our test.

Powered by WordPress