Use mod_deflate to Compress Web Content Delivered by Apache – Make Blog More Responsive

by on November 16th, 2008

One of the most efficient methods to reduce the usage of bandwidth by the web server and, at the same time, increase the speed of the content delivery is to compress your web pages and, generally, all output that is returned to the clients. This article describes how to use the mod_deflate module to compress Apache’s output on-the-fly. You can make your website or blog respond faster by using this method.

Create a file named deflate.conf and import it in the main server’s configuration using the Include directive.

(Include /path/to/deflate.conf):
# mod_deflate configuration
LoadModule deflate_module modules/
<IfModule mod_deflate.c>
        AddOutputFilterByType DEFLATE text/plain
        AddOutputFilterByType DEFLATE text/html
        AddOutputFilterByType DEFLATE text/xml
        AddOutputFilterByType DEFLATE text/css
        AddOutputFilterByType DEFLATE application/xml
        AddOutputFilterByType DEFLATE application/xhtml+xml
        AddOutputFilterByType DEFLATE application/rss+xml
        AddOutputFilterByType DEFLATE application/javascript
        AddOutputFilterByType DEFLATE application/x-javascript
        DeflateCompressionLevel 9
        BrowserMatch ^Mozilla/4 gzip-only-text/html
        BrowserMatch ^Mozilla/4\.0[678] no-gzip
        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
        DeflateFilterNote Input instream
        DeflateFilterNote Output outstream
        DeflateFilterNote Ratio ratio
        LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate

This configuration will be inherited by all virtual hosts.

To disable it just comment out the line that loads the mod_deflate module (#LoadModule deflate_module modules/

To record mod_deflate’s specific variable (instream, outstream, ratio) values for a virtual host, just add a new log file of type deflate:

CustomLog /path/to/vhost/logs/deflate_log deflate

This will give you an idea of how efficient is the use of mod_deflate in that particular host.

Read More About mod_deflate
mod_deflate to compress web content by apache

I asked my host support about it. They told me that they already do this technique for every website. wow. Happy Hosting, Happy Customer :)

Do you compress your web content? What method do you prefer?


One Review

  1. ALI says:

    This is Advanced type. You can use gZip Compression via htaccess.
    Some cool htacces tricks I found at

    Have a good day.