What is the difference between GZIP and DEFLATE?
Short answer
GZIP and DEFLATE are two content-codings used to compress HTTP responses, and both use the same DEFLATE compression algorithm; the difference is in how the compressed data is packaged. gzip carries the data with a longer header and a CRC-32 check, and deflate with a shorter zlib wrapper. gzip is the format most widely supported by clients. In TR7, the algorithm is selected in the Compression Algorithm field of the Compression profile (GZIP or DEFLATE; default GZIP). TR7 compresses the response only for requests in which the client states in the Accept-Encoding header that it accepts the selected algorithm (client compatibility check); for other requests, the response goes uncompressed.
Where It Is Used in TR7
| Where | Field / label | What for |
|---|---|---|
| Load Balancer → Profiles (L4-L7 Behavior Sets) → Compression | Compression Algorithm: GZIP (default), DEFLATE | The compression format of the responses; a single algorithm is selected in the profile |
| HTTP vService form → Details | Compression | Assigning the Compression profile to the vService |
Comparison
| gzip | deflate | |
|---|---|---|
| Compression algorithm | DEFLATE (RFC 1951) | DEFLATE (RFC 1951) |
| Wrapper | gzip format (RFC 1952): longer header, CRC-32 | zlib format (RFC 1950): short header, Adler-32 |
| Header in the response | Content-Encoding: gzip | Content-Encoding: deflate |
| Client support | Most widespread | More limited; some clients expect data without a wrapper |
The content-coding definitions in HTTP are in the RFC 9110 · Content Codings section. Enabling compression and the content types to compress: How is compression (GZIP / DEFLATE) enabled; which content types should be compressed?
Common Misconceptions
- "DEFLATE should always be preferred because it gives smaller output." The two formats use the same algorithm; the only difference between them is a wrapper of a few bytes. Compatibility matters more than this difference; for general use, GZIP is selected.
- "The algorithm is applied regardless of the client." If the client has not stated the selected algorithm in Accept-Encoding, the response is sent uncompressed.
- "The algorithm determines the compression ratio." The ratio and the CPU usage are determined by the Compression Level field in the profile; the algorithm selects only the format.
How it is done in the documentation
