Use mod_deflate or gzip for centos5+apache

Posted on

Use mod_deflate or gzip for centos5+apache – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about apache-2.2, centos, gzip, deflate, .

I’d like to compress the JS and CSS (perhaps also html?) files that I’m sending out. I’ve read a lot about gzip and mod_deflate but I’m not really sure what’s the best to use?

I’m looking for the easiest thing to maintain and to reduce bandwidth on my web app.

Solution :


mod_deflate is the module available to achieve Gzip compression in Apache2.

mod_gzip in Apache1 has been replaced with mod_deflate in Apache2.

It does a really good job at compressing.

Sample config

Here’s a sample configuration which compresses HTML, CSS, JS, RSS (depending on the browser):

<IfModule mod_deflate.c>
          # these are known to be safe with MSIE 6
          AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xhtml+xml

          # everything else may cause problems with MSIE 6
          AddOutputFilterByType DEFLATE text/css
          AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
          AddOutputFilterByType DEFLATE application/rss+xml

      BrowserMatch ^Mozilla/4 gzip-only-text/html
      BrowserMatch ^Mozilla/4.0[678] no-gzip
      BrowserMatch bMSIE !no-gzip !gzip-only-text/html

      DeflateFilterNote Input input_info
      DeflateFilterNote Output output_info
      DeflateFilterNote Ratio ratio_info
      LogFormat '"%r" %{output_info}n/%{input_info}n (%{ratio_info}n%%)' deflate
      CustomLog /var/log/apache2/deflate_log deflate


Also, here’s a tutorial about mod_deflate for Apache2.

It looks like mod_gzip was renamed to mod_deflate in Apache 2.

Of note in the article is that anything under 1K in size isn’t really worth compressing. The mod_deflate page states that it doesn’t compress images either (I’d post the link but I lack the reputation).

Leave a Reply

Your email address will not be published. Required fields are marked *