压缩浏览器兼容性和相对于 GZIP 的优势


更新日期: 2012年2月10日:

ZOompf 已经完成了一些非常深入的研究,就这个主题 给你。它胜过任何发现以下。


更新日期: 2010年9月11日:

为此 给你搭建了一个测试平台




HTTP 1.1对 GZIP 和 DEFLATE (zlib)的定义提供了一些背景信息:

“‘ Gzip’是 Gzip 格式,“ flate”是 zlib 格式 或许应该把第二个命名为“ zlib”,以避免 与原始的平减压缩数据格式的混淆 1.1 RFC 2616正确地指向 RFC 1950中的 zlib 规范 对于“瘪气”传输编码,有报道称 服务器和浏览器不正确地生成或预期原始泄气 根据 RFC 1951中的放气规范的数据,最值得注意的是 微软产品 Zlib 格式将是更有效的方法(< em > ,实际上 Zlib 格式是为 设计的,使用‘ gzip’传输 编码可能是更可靠的,由于一个不幸的选择 ”(资料来源: http://www.gzip.org/zlib/zlib_faq.html)

因此,我的问题是: 如果我发送没有 zlib 包装器(或 gzip, 有没有现代的浏览器(如 IE6及以上版本、 FF、, Chrome 浏览器,Safari 浏览器等) ,不能理解原始泄气 压缩数据(假设 HTTP 请求头“ Accept-Encoding”包含“ flate”) ?

平减数据总是比 GZIP 小几个字节。

如果所有这些浏览器都能成功解码数据,那么 发送 RAW 泄气而不是 zlib 有什么缺点吗?



更新日期: 2010年9月11日:

为此 给你搭建了一个测试平台

37991 次浏览

as far as i know, yes - pretty much you "can always send raw DEFLATE and everything would be okay"... there is not "always", but most of all cases. if not, this is the browser's problem.

The Android 1.6 browser (v4) fails both the zlib and the deflate test on your page. I've added it to your list.

Isn't it the case that AddOutputFilterByType DEFLATE using mod_deflate sends by gzip by default?

UPDATE: Browsers have been dropping support for raw deflate. zOompf has completed some very thorough research on this very topic here. Unfortunately, it appears that raw deflate is NOT safe to use.


Check http://www.vervestudios.co/projects/compression-tests/results for more results.

Here are the browsers that have been tested:

/*  Browser                       DEFLATE      ZLIB     */
XP Internet Explorer 6        PASS         FAIL
XP Internet Explorer 7        PASS         FAIL
XP Internet Explorer 8        PASS         FAIL
Vista Internet Explorer 8     PASS         FAIL
XP Firefox 3.6.*              PASS         PASS
XP Firefox 3.5.3              PASS         PASS
XP Firefox 3.0.14             PASS         PASS
Win 7 Firefox 3.6.*           PASS         PASS
Vista Firefox 3.6.*           PASS         PASS
Vista Firefox 3.5.3           PASS         PASS
XP Safari 3                   PASS         PASS
XP Safari 4                   PASS         PASS
XP Chrome 3.0.195.27          PASS         PASS
XP Opera 9                    PASS         PASS
XP Opera 10                   PASS         PASS
XP Sea Monkey 1.1.8           PASS         PASS
Android 1.6 Browser (v4)*     N/A          N/A
OS-X Safari 4                 PASS         PASS
OS X Chrome 7.0.517.44        PASS         PASS
OS X Opera 10.63              PASS         PASS
iPhone 3.1 Safari             PASS         PASS

* Android Sends HTTP request header "Accept-Encoding: gzip". Deflate is not permitted.


I conclude that we can always send raw DEFLATE (when the HTTP request header "Accept-Encoding" contains "deflate") and the browser will be able to correctly interpret the encoded data. Can someone prove this wrong?

note: .NET's native implementation of DEFLATE (System.IO.Compression.DeflateStream) is raw DEFLATE. It also sucks. Please use zlib.net for all of your .NET deflating needs.