How to enable Apache compression with mod_deflate

Apache comes standard with the mod_deflate module that enable you to compress the content of web pages before they are sent over the wire. Please note that you should probably disable other compressors (like PHP compression, if enable) before using the Apache compression feature.

To enable compression under Apache with the module mod_deflate, please follow these instructions:

1) Modify your httpd.conf to load the mod_deflate module with:
LoadModule dir_module modules/mod_deflate.so

2) Add the following directives to your httpd.conf:
SetOutputFilter DEFLATE
DeflateCompressionLevel 9
#1 to 9: 9 is the most compressed
#The following statement indicate which document types not to compress. Many type of documents do not compress well.
#At the end (Appendix 1) of this article some more type you might wish to also exclude from compression
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary

Alternatively you can enable compress by specifying which documents you wish to compress like:
AddOutputFilterByType DEFLATE text/html text/plain text/xml
or
AddOutputFilterByType DEFLATE text/*
AddOutputFilterByType DEFLATE application/ms* application/vnd* application/postscript

Here are the result on www.sitebuddy.com when enabling compression:

Original size: 24575 bytes
 

Compressed size:6856 bytes
 

Savings:17719 bytes
 

Percentage saved by compression:73.0%
Transfer speed improvement: 3.5 X

Test your compression using: http://www.port80software.com/support/p80tools

Appendix 1:
SetEnvIfNoCase Request_URI \.wmv$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.wma$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.swf$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.wav$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.wmd$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.wmz$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.mcf$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.wmx$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.wm$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.wax$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.asf$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.rm$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pls$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.asx$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.mpg$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.mp2$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.mp3$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.avi$ no-gzip dont-vary



"Apache comes standard with

"Apache comes standard with the mod_deflate module that enable you to compress the content of web pages before they are sent over the wire. Please note that you should probably disable other compressors (like PHP compression, if enable) before using the Apache compression feature."
Thanks for the information