Mod Deflate comes built into Apache, but is not enabled by default. This tutorial will explain the simplest way of enabling it and setting which mime times to compress. Mod Deflate will increase your server load, but decreases the amount of time that clients are connected and can usually reduce the page size by 60 to 80 percent.
Loading Mod Deflate
First make sure that you are loading mod_deflate.so, this line should be at the top of your httpd.conf file and is usually loaded by default.LoadModule deflate_module libexec/apache22/mod_deflate.so
Mod Deflate Settings
Second create a new config file to keep the deflate options in.This file will be included in the main httpd.conf file. Inside the file add the following:# ee /usr/local/etc/apache22/Include/mod_deflate.conf
AddOutputFilterByType DEFLATE text/html text/plain
#Highest 9 - Lowest 1
DeflateCompressionLevel 9
#Optional
#Skip browsers with known problems
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
#Optional
#Logging
DeflateFilterNote ratio
LogFormat '"%r" %b (%{ratio}n) "%{User-agent}i"' deflate
CustomLog /usr/local/www/logs/deflate_log deflate
The compression level can be adjusted. 9 gives the highest compression, the smallest file sizes, and also uses the most CPU cycles.Once you have this config file added restart apache.
# apachectl graceful











