Compressing ur web content using Apache mod_deflate

Posted on January 22, 2012


I am assuming Apache 2.x web server

Step 1 – Make sure mod_deflate is loaded

Make sure the following line is in httpd.conf

LoadModule deflate_module modules/

Step 2  – Add the following to u’r httpd.conf

# Method 2: Compress all content, manually excluding specified file types like images
<IfModule mod_deflate.c>
# place filter ‘DEFLATE’ on all outgoing content
SetOutputFilter DEFLATE
# exclude uncompressible content via file type
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|rar|zip)$ no-gzip
<IfModule mod_headers.c>
# properly handle requests coming from behind proxies
Header append Vary User-Agent

#3. Restart Apache

You can test this with YSlow … just make sure u remove all browser caching before checking …

Posted in: Performance