Apache 2.x performance tweaking with mod_deflate and misc other tweaks
Jul 18
Roughly three weeks ago I updated JKOgden.net’s back-end and front-end; this is more of an intermediate’s guide to enabling mod_deflate and other tweaks and is partly intended for VPS servers as far as enabling mod_deflate.
First I’d like to talk a little about mod_deflate, first and foremost the module needs to be enabled in your Apache 2.x configuration so if it is not already you must recompile Apache and if you’re going to do that I would also suggest installing APC Accelerator which is a caching system for PHP. I have read some articles that you can add code to your .htaccess file to enable mod_deflate without having it enabled in your Apache configuration, however I have found that not to be true by looking into Apache log (/usr/local/apache/logs/error_log).
What is mod_deflate and why is it so important? When you request a file such as http://www.jkogden.net/index.php, your browser talks to a web server. The conversation looks a little like this:
- Browser: GET /index.php HTTP 1.1 Accept-encoding gzip,deflate
- Server: looks for index.php (/var/www/…/index.php)
- Server: HTTP/1.x 200 OK No encoding available 300KB <html></html>
- Browser: 300KB? Whoa, that’s a lot of data
As you can see, with all of the html tags, text, etc the text is quite large and is an inefficient usage of bandwidth.
What do you normally do when a file is too big to send? You use your favorite compression utility and zip it. If we could send a .zip file to the browser (index.php.zip) instead of plain old index.php, we’d save on bandwidth and download time. The browser could download the zipped file, extract it, and then present it to user.
Here’s an updated conversation when accessing a site configured with mod_deflate:
- Browser: GET /index.php HTTP 1.1 Accept-Encoding: gzip,deflate
- Server: looks for index.php (/var/www/…/index.php)
- Server: HTTP/1.x 200 OK Content-Encoding: gzip 30KB
- Browser: 30KB? Nice, let me unzip it





