Skip to content

Compression basics for software developers

Posted: October 31st, 2005 | Filed under: Uncategorized

All modern browsers can decompress gzipped or deflate-encoded content, what we all mean when we speak about HTTP compression.  But what if you are building the browser or a similar type of application yourself?  If you are building a custom client application to handle decompression where a browser would traditionally do the chore, this post helps to lay the ground for how compression works between a Web client and server.

If your client program is sending the Accept-Encoding HTTP header, then httpZip or ZipEnable managing IIS 6 native compression (or any other compression solution) should be responding with the first compression scheme specified by that header’s value.  So, in other words, if the client is sending:

Accept-Encoding: gzip


Accept-Encoding: gzip, deflate

Then the server running httpZip should be responding with gzip-encoded data (which would be accompanied by the HTTP header “Content-Encoding: gzip”).  If, on the other hand, the client is sending:

Accept-Encoding: deflate


Accept-Encoding: deflate, gzip

Then the response from the httpZip-enabled server should be deflate-encoded data (which would be signaled by the HTTP header “Content-Encoding: deflate”).

Both the “deflate” and the “gzip” encodings are done using the standard zlib library ( ).  There is often some confusion about these terms, due mostly to the loose usage of “deflate.”  What is called “deflate” in the HTTP headers is actually the raw deflate compression format specified in RFC1951 ( ) *plus* the zlib headers and checksums specified in RFC1950 ( ). 

Similarly, what is called “gzip” in the HTTP headers is the raw deflate of RFC1951 plus the gzip headers and checksums specified in RFC1952 ( ).  So, in both cases, you are dealing with the basic deflated stream, wrapped in one or another type of header-and-checksum scheme.

How do you handle the decompression part in your futuristic, ultra-performing Web app?  These guys at Exceed have a nice decompression library that you can purchase: