HTML and CSS Reference
compression method currently available and generally reduces the response size by
about 70%. DEFLATE is a patent-free compression algorithm for lossless data com‐
pression. There are numerous open source implementations of the algorithm. Apache's
mod_deflate module is one implementation that many developers are familiar with.
To learn more about the differences between GZIP and DEFLATE
compression, see Billy Hoffman's excellent article at http://zoompf.com/
Approximately 90% of today's Internet traffic travels through browsers that claim to
support GZIP. All browsers supporting DEFLATE also support GZIP, but all browsers
that support GZIP do not support DEFLATE. Some browsers, such as Android, don't
include DEFLATE in their Accept-Encoding request header. Because you are going to
have to configure your web server to use GZIP anyway, you might as well avoid the
whole mess with Content-Encoding: deflate .
The Apache module that handles all HTTP compression is mod_deflate . Despite its
name, mod_deflate doesn't support DEFLATE at all. It's impossible to get a stock version
Apache, does not support DEFLATE at all and sends only GZIP-compressed responses.
Sending an Accept-Encoding: deflate request header will result in an uncompressed
If you use Apache, the module configuring GZIP depends on your version: Apache 1.3
vention, both use GZIP under the hood.
The following is a simple example of how to match certain file types to include in HTTP
compression. You would place it in the .htaccess file in Apache 2.4:
AddOutputFilterByType DEFLATE text/html text/plain
Here's a more complex example that deals with browser inconsistencies can be set as
follows to compress everything except images:
# Insert filter
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0 no-gzip