since 1999


2 minutes estimated reading time.

mod_deflate: Dramatic website speed increase with Apache compression on Ubuntu Linux

Last Updated on October 6, 2013. {% render_partial _includes/ %}

It’s easy to dramatically improve the loading speed of your website by enabling compression support in your Apache web server. This works without needing to make any changes to your backend or database code no matter what programming platform your development team uses.

I recently added this change to a Ruby on Rails-based web application running on a Ubuntu Linux dedicated virtual server. That particular page observed a 72% decrease in bandwidth required to deliver the homepage.

It has been my experience with our internal and with client RoR sites that mod_deflate tends to provide a 62% to 72% savings on bandwidth required to deliver each page. This is significant for visitors on slower connections or mobile phones. It is well worth enabling for most applications.

Three Easy Steps

Step 1: Enable mod_deflate in your Apache2 installation

sudo a2enmod deflate

Step 2: Edit /etc/apache2/httpd.conf to configure mod_deflate to compress certain file types

<IfModule mod_deflate.c>
  # compress text, html, javascript, css, xml:
  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
  AddOutputFilterByType DEFLATE image/x-icon

Step 3: Restart Apache to enable the changes

sudo apachectl graceful

Test if it Worked

Once you have made the changes, test if the deflate is working properly by browsing through the website with all of your browsers. Then confirm that the connection is running deflate using a third party tool. One such is


{% render_partial _includes/callouts/ %}

Revision History

As a maintained post, this document is updated from time to time.