deflate--outdated Web compression format, it is best to disable [go]

Source: Internet
Author: User
Tags rfc

When you set up gzip, you find that you have a deflate compression setting at the same time, and you do not understand deflate compression at first, so that deflate compression is enabled while Gzip is enabled. While setting gzip and deflate compression does not affect the proper functioning of the site, the answer returned when the site is checked for gzip is enabled. But can we not set deflate compression? Or, do you need to disable deflate compression? What are the advantages and disadvantages of deflate compression? With this pile of questions, I checked some information today, probably learned some, and finally concluded that: deflate--outdated Web compression format, it is best to disable.

Learn about gzip and deflate

GZIP, as if it were an opaque or atomic function. In fact, HTTP defines a mechanism by which a Web client and Web server agree that a compression scheme can be used to send content, which is done using the accept-encoding and content-encoding headers. There are two common HTTP compression types: Deflate and gzip.

Deflate is a non-patented compression algorithm, it can achieve lossless data compression, there are many open-source implementation algorithms. The standard implementation Library is used by most people zlib. The Zlib library provides data for compression and decompression using Deflate/inflate. The Zlib library also provides a data format that confuses the named Zlib, which wraps deflate compressed data, with headers and checksums.

Gzip is another compression library that uses deflate to compress data. In fact, most implementations of Gzip actually use the internal deflate/inflate compression operation of the Zlib library. Gzip produces its own data format, confusing named Gzip, which wraps deflate compressed data, with headers and checksums.

Early browsers describe confusion about deflate compression

http/1.1 RFC (Hypertext Transfer Protocol version http/1.1) does poorly when describing allowable compression schemes for accept-encoding and content-encoding headers, it defines Content-encoding:gzip, The response body consists of the use of the GZIP data format (gzip header, compressed data, and checksum). It also defines content-encoding:deflate, but, despite its name, this does not mean that the response body is the original block of DEFLATE compressed data. According to Rfc-2616,deflate and content-encoding:deflate, it actually means that the response body is composed of the zlib format (zlib header, compressed data, and checksum).

This "Deflate logo does not mean that the original deflate compressed data" idea is quite chaotic. Earlier versions of Microsoft's IIS Web server were programmed to return the original deflate compressed data accept-encoding::deflate requirements Instead of a zlib-formatted response. While in the content-encoding with the expected response natural version of the Internet Explorer:deflate header has the original deflate response body.

Mark Adler,zlib, one of the authors of the presentation, said:

Early Microsoft servers mistakenly provide "Deflate" of raw compression (such as RFC1951 's data without a RFC1950 zlib wrapper). The problem with this is that the browser has to try both ways, at the end it just uses more reliable gzip.

Now the browser is not good for deflate compression

As Mark says, after the browser receives content-encoding, compression must handle two possible situations: the response body is the original deflate data, or the response body is zlib wrapped deflate response. So how good is the modern browser handling deflate or zlib packaged deflate response? Verve Studio tested a large number of browsers, and the results were not good.

Some of the results in the table mean that the browser handles the original deflate or zlib wrapped deflate inconsistency, which is actually another way of saying "it's broken, it's not functioning properly." "It seems like a tricky mistake, and browser creators are constantly re-introduced into their products. Safari browser 5.0.2? No problem. Safari browser 5.0.3? Completely failed. Safari browser 5.0.4? No problem. Safari browser 5.0.5? Inconsistent and destroyed.

Sending raw deflate data is not a good idea, as Mark says, "[it] uses only more reliable gzip." ”

It should also be noted that all browsers that support deflate support gzip, but not all gzip-enabled browsers support deflate. Some browsers, such as Android, do not contain deflate compression in their accept-encoding request headers. Since you have to configure your Web server to use gzip, you might as well avoid content-encoding:deflate.

Disable deflate

Fortunately, it's not that difficult to avoid deflate.

Apache handles all HTTP compression modules as Mod_deflate modules. Despite its name, the Mod_deflate module does not support deflate at all. It is not possible to get a Apache2 version of the deflate that is sent to the original deflate or zlib wrapper. Nginx, such as Apache, does not support deflate, it only sends gzip compressed responses, and sending Accept-encoding:deflate request headers will result in uncompressed responses.

Microsoft's IIS Web server can send both gzip and deflate responses, and you can enable or disable each scenario individually. For IIS6, you can edit metabase to disable deflate support. For IIS7, you can disable deflate by editing the <schemes> deflate Compression Scheme section of the

If your Web server sends compressed deflate content, both free and commercial products have built-in detection, "outdated compression format."

Detecting Web pages using gzip or deflate compression

Detecting Web pages using gzip or deflate compression, some online tools, such as the gzip compression detection (http://pagespeed.webkaka.com/youhua/gzip/) of the card network, can be used.

gzip Compression detection

It is important to note that gzip compression is compressed by file, and it is not detected that the Web page has gzip enabled and all files have gzip enabled. In many cases, the Web page is enabled for gzip, but the discovery of the JS file does not enable gzip, due to improper settings.

How do I know which files on a webpage have gzip enabled, and which files are not yet enabled for gzip? You can use the card network's website Speed Diagnostic Tool (http://pagespeed.webkaka.com/) to view it in one click. For example, take a look at the following test results:

The HTML page has successfully enabled gzip compression

The CSS file did not successfully enable gzip compression

This is because gzip compression is enabled only for HTML pages, but not for other files such as CSS.

deflate--outdated Web compression format, it is best to disable [go]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.