Last Updated on October 6, 2013. This post is one of the most visited on this blog and is a maintained post that is periodically updated to be most useful to you. For more, see the list of all maintained posts.
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
1 2 3 4 5 6 7 8 9 10 11 12 13
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 http://www.whatsmyip.org/http-compression-test/.
Invitation to the Web Application Topics Newsletter
This post is part of the Web Application Topics series. If you are interested in having future issues sent directly to you by e-mail, please sign up for free, today. For back issues, see the Web Application Topics category on this blog.
As a maintained post, this document is updated from time to time.
- October 6, 2013: Promoted to a Maintained Post status
- September 3, 2013: Reformatted as part of the migration to the new blog.
- April 18, 2012: Originally posted on The Rietta Blog, hosted on the Blogger platform