Here are some recommended settings of the mod_deflate in Apache2. The main principle is to define which type of files are and which ones are not to be compressed. These settings DON’T override the fact that if a device/browser doesn’t have the following header in its request the requested file/component will NOT be compressed at all.
Accept-Encoding: gzip,deflate
References:
http://www.philchen.com/2009/08/04/apache-mod_deflate-and-flash-swf-files-dont-like-each-other
httpd.apache.org/docs/2.2/mod/mod_deflate.html
mod_deflate directives
Warning: it also includes a mod_header directive, therefore the mod_headers must also be loaded.
# Turn on the compression for all files ... except for the file types defined below.
SetOutputFilter DEFLATE
#
# Use maximum compression (More CPU intensive)
DeflateCompressionLevel 9
#
###############################
# Exceptions to the above rule
###############################
# Don't compress audio files
SetEnvIfNoCase Request_URI \.(?:wma|aif|iff|m3u|m4a|mid|mp3|mpa|ra|wav|wma)$ no-gzip dont-vary
#
# Don't compress video files
SetEnvIfNoCase Request_URI \.(?:3g2|3gp|asf|asx|avi|flv|mov|mp4|mpg|rm|srt|swf|vob|wmv)$ no-gzip dont-vary
#
# Don't compress already compresses files
SetEnvIfNoCase Request_URI \.(?:7z|cbr|deb|gz|pkg|rar|rpm|sit|sitx|tar.gz|t?gz|zip|bz2|zipx)$ no-gzip dont-vary
#
# Don't compress executable files
SetEnvIfNoCase Request_URI \.(?:apk|app|bat|cgi|com|exe|gadget|jar|pif|vb|wsf)$ no-gzip dont-vary
#
# Don't compress Raster Image Files
SetEnvIfNoCase Request_URI \.(?:bmp|dds|dng|gif|jpe?g|png|psd|psp|tga|thm|tif|yuv)$ no-gzip dont-vary
#
# Don't compress document files
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
#
# Don't compress anything for special old browsers
BrowserMatch ^Mozilla/4\.0[678] no-gzip
#
# Compress only text if Mozilla 4
BrowserMatch ^Mozilla/4 gzip-only-text/html
# but turn compression back on Microsoft Internet Explorer who disguise itself as 'Mozilla 4' ;-)
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
#
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
#
# Preparation for compression ratio report in logs
DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
# Example of log format that uses the above DeflateFilterNote information to display the compression rate
# LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
Here is a list of files extensions used to build the above file exclusions rules.
Reference:http://www.fileinfo.com/filetypes/common
Audio Files
.aif Audio Interchange File Format
.iff Interchange File Format
.m3u Media Playlist File
.m4a MPEG-4 Audio File
.mid MIDI File
.mp3 MP3 Audio File
.mpa MPEG-2 Audio File
.ra Real Audio File
.wav WAVE Audio File
.wma Windows Media Audio File
Video Files
.3g2 3GPP2 Multimedia File
.3gp 3GPP Multimedia File
.asf Advanced Systems Format File
.asx Microsoft ASF Redirector File
.avi Audio Video Interleave File
.flv Flash Video File
.mov Apple QuickTime Movie
.mp4 MPEG-4 Video File
.mpg MPEG Video File
.rm Real Media File
.srt SubRip Subtitle File
.swf Shockwave Flash Movie
.vob DVD Video Object File
.wmv Windows Media Video File
Compressed files
.7z 7-Zip Compressed File
.cbr Comic Book RAR Archive
.deb Debian Software Package
.gz Gnu Zipped Archive
.pkg Mac OS X Installer Package
.rar WinRAR Compressed Archive
.rpm Red Hat Package Manager File
.sit StuffIt Archive
.sitx StuffIt X Archive
.tar.gz Compressed Tarball File
.zip Zipped File
.zipx Extended Zip File
Executable files
.apk Android Package File
.app Mac OS X Application
.bat DOS Batch File
.cgi Common Gateway Interface Script
.com DOS Command File
.exe Windows Executable File
.gadget Windows Gadget
.jar Java Archive File
.pif Program Information File
.vb VBScript File
.wsf Windows Script File
Raster Image Files
.bmp Bitmap Image File
.dds DirectDraw Surface
.dng Digital Negative Image File
.gif Graphical Interchange Format File
.jpg JPEG Image
.png Portable Network Graphic
.psd Adobe Photoshop Document
.pspimage PaintShop Pro Image
.tga Targa Graphic
.thm Thumbnail Image File
.tif Tagged Image File
.yuv YUV Encoded Image File