Gzipping content delivery with Apache on Red Hat

Ever used YSlow? It is a tool from the Yahoo Developer Network which gives some insight into possible performance problems (though it should certainly not be used alone to evaluate web site performance). See Dries Buytaert talk more about it here or even better see Chapter 13 of High Performance Web Sites: Essential Knowledge for Front-End Engineers. One of the suggestions it gives is to gzip content delivery.

Since I am hosting on a Red Hat Enterprise Linux box, I wanted to figure out the easiest steps to gzipping my content delivery without much hassle. The steps should be the same on almost all flavors of Linux, but only tested on RHEL 5:

  1. Open etc/httpd/conf/httpd.conf in your favorite text editor (e.g., vim)
  2. Enable mod_deflate in httpd.conf by uncommenting #LoadModule deflate_module modules/mod_deflate.so (that means remove the #)
  3. Put the following in a .htaccess file (bonus if you are using Drupal you have a .htaccess file already in your root Drupal folder):
    <IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
    </IfModule>
  4. Restart Apache. In Red Hat from the root folder do /etc/init.d/httpd restart.

This of course is just one of the many steps of optimizing for performance. If you are using Drupal the best step you can do is turn on Normal caching. For more tips, see Chapter 22: Optimizing Drupal in Pro Drupal Development.

 

Comment using an existing account (Google, Twitter, etc.)