Why do real-world servers prefer gzip over deflate encoding?

HttpEncodingCompressionGzipDeflate

Http Problem Overview


We already know deflate encoding is a winner over gzip with respect to speed of encoding, decoding and compression size.

So why do no large sites (that I can find) send it (when I use a browser that accepts it)?

Yahoo claims deflate is "less effective". Why?

I maintain HTTP server software that prefers deflate, so I'd like to know if there's some really good reason not to continue doing so.

Http Solutions


Solution 1 - Http

There is some confusion about the naming between the specifications and the HTTP:

  • DEFLATE as defined by RFC 1951 is a compressed data format.
  • ZLIB as defined by RFC 1950 is a compressed data format that uses the DEFLATE data format.
  • GZIP as defined by RFC 1952 is a file format that uses the DEFLATE compressed data format.

But the HTTP uses a different naming:

> * gzip An encoding format produced by the file compression program "gzip" (GNU zip) as described in RFC 1952 [25]. This format is a Lempel-Ziv coding (LZ77) with a 32 bit CRC. > > * deflate The "zlib" format defined in RFC 1950 [31] in combination with the "deflate" compression mechanism described in RFC 1951 [29].

So to sum up:

  • gzip is the GZIP file format.
  • deflate is actually the ZLIB data format. (But some clients do also accept the actual DEFLATE data format for deflate.)

See also this answer on the question What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?:

> What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings? > > "gzip" is the gzip format, and "deflate" is the zlib format. They should probably have called the second one "zlib" instead to avoid confusion with the raw deflate compressed data format. While the HTTP 1.1 RFC 2616 correctly points to the zlib specification in RFC 1950 for the "deflate" transfer encoding, there have been reports of servers and browsers that incorrectly produce or expect raw deflate data per the deflate specification in RFC 1951, most notably Microsoft. So even though the "deflate" transfer encoding using the zlib format would be the more efficient approach (and in fact exactly what the zlib format was designed for), using the "gzip" transfer encoding is probably more reliable due to an unfortunate choice of name on the part of the HTTP 1.1 authors.

Solution 2 - Http

From my minimal testing it appears most HTTPds either:

  1. don't support deflate on-the-fly: Apache's mod_deflate (a suprise), GWS
  2. or prefer to send gzip: IIS, lighttpd's mod_compress

So to send deflate on the most popular server (Apache), you must maintain pre-encoded files and use mod_negotiate (you might even have to use type-maps to prefer deflate).

I'd guess, due to this hassle, deflate is just rarely used, and therefore bugs are more likely to exist in client deflate support than in gzip support.

Solution 3 - Http

Check this website for more information: http://web.archive.org/web/20120321182910/http://www.vervestudios.co/projects/compression-tests


Deflate, per spec, is actually http://zlib.net/">zlib</a> (a compression format developed specifically for streaming content over the web)...which is a wrapper around deflate.

Internet Explorer, however, incorrectly implements HTTP 1.1 deflate (zlib) as raw deflate. So if your server sends correct HTTP 1.1 deflate (zlib) content to IE it chokes.

I've researched the topic a bit and it looks safe to ALWAYS send raw deflate to modern browsers...just make sure its is, in fact, raw and not zlib.

Check this article for more information > https://stackoverflow.com/questions/1574168/gzip-vs-deflate-zlib-revistited">Gzip vs Deflate (zlib) revisited.

So I think that there is a good reason TO continue sending deflate over gzip.

Solution 4 - Http

As far as I know (disclaimer: and I'm not an expert here, just what I've heard), gzip uses the same algorithm as deflate but it has more header stuff that make it have a larger size (relative to deflate). However, I think deflate is supported by less clients and proxies.

Solution 5 - Http

I wondered the same thing :). I think it might be to do with compatibility of older (possibly ancient) browsers. I read somewhere that older browsers are more likely to creep out at deflated content that mod_gzipped in certain instances(?) but googling this led me to conclude that it's probably best to stop googling it.

Solution 6 - Http

ActionScript 3 has native deflate support, but for gzip you need to use an external library

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSteve ClayView Question on Stackoverflow
Solution 1 - HttpGumboView Answer on Stackoverflow
Solution 2 - HttpSteve ClayView Answer on Stackoverflow
Solution 3 - HttpDavid MurdochView Answer on Stackoverflow
Solution 4 - HttpmmxView Answer on Stackoverflow
Solution 5 - Httpkarim79View Answer on Stackoverflow
Solution 6 - HttpAlexander FarberView Answer on Stackoverflow