GZip compression is a simple, effective way to save bandwidth and speed up your site. For anybody using Apache HTTPD here is a simple walk through of the steps required to enable it.
Note that there is a side effect of enabling gzip compression you need to be aware of.
By adding a compression step to your server you are increasing the cpu cost of each resource request. If your server is already under heavy load this additional overhead could be a serious downside. Only you can judge if the benefits outweigh the costs.
So lets get started.
The first step to adding compression is to install the mod_deflate module. If you dont have it already then you can download it from the module page of the apache httpd project website and add it to your httpd modules directory. Slackware comes with this module already present.
Once you have confirmed the mod_deflate module exists open the "httpd.conf" file and either add or un-comment the LoadModule directive for mod_deflate.
With the module enabled we must now tell Apache HTTPD what type of files we want it to compress. To do this we create a file named httpd-deflate.conf (this is my naming convention but you can actually name it anything you want).
Lets tell Apache that we want to gzip all files except those file formats which we know are already compressed. We also put in some browser specific compression rules. Copy the following code into the httpd-deflate.conf and save it.
At this stage you can choose to load our deflate rule set for all sites or per vhost. To load the rule set it for all sites place this line in httpd.conf.
If you just want to use these rules for one website put this command in the body of that individual vhost in the "httpd-vhost.conf" file.
Finally we save our changes and restart apache httpd. For Slackware folks here is the restart command for apache.
In my previous deflate file we compressed everything except a list of excluded types. An alternative approach is to only compress for named types (for example html, css, js). Here is a deflate rule set I have used this approach.