How to run a site with gzip compression and why it matters
Since Google is now considering site speed for PageRank, it has made developers and SEO crowd thinking about it. Those familiar with Google Webmaster Tools probably know that site speed graph and related suggestions have been there for quite some time already.
First and probably the simplest thing is to turn on GNU zip compression, as also advised by Google Webmaster Tools (under Labs > Site performance). Doing so requires mod_deflate module on the Apache web server.
Turning on gzip
Given the above, enabling the compression couldn't be easier with only 1 line in the .htaccess of the site:
All it does is to turn on Gzip compression for each listed mime type. All browsers in use today can handle it.
For better readability a block of directives could be used instead:
If there's uncertainty about whether or not Apache has mod_deflate, it's be smart to make it fail-safe by wrapping the directive(s) inside the IfModule section as Cezary pointed out in the comment below.
To illustrate the benefits, the directive was introduced on 7Kohvipoissi.ee. Here's the chart with page load speeds over 10 tests:
Data sheet (PDF, 45 KB)
- Online Gzip test to test the compression
- .htaccess (Wikipedia)
- GNU Gzip (Wikipedia)
- mod_deflate Apache Module
- Google Webmaster Tools