Gzip and Brotli are HTTP content encodings that reduce transferred text bytes when the server and browser negotiate a supported encoding.
Decision rule and boundaries
Gzip and Brotli are HTTP content encodings that reduce transferred text bytes when the server and browser negotiate a supported encoding. Content encoding is negotiated between client and server: a browser advertises acceptable encodings and the server returns a representation with Content-Encoding. It is most useful for compressible HTML, CSS, JavaScript, JSON, and SVG—not for already-compressed images or archives.
How to inspect it
Request a representative document with and without accepted encodings, then compare headers, transfer size, cache variation, and successful decoding. Confirm that an intermediary does not serve a Brotli representation to a client that did not negotiate it.
Practical workflow
Enable compression at the layer that owns delivery, keep Vary: Accept-Encoding where shared caching requires it, and verify a cold and cached response. Measure transfer bytes separately from server response time and rendering work.
Common mistakes and measurement limits
A smaller transfer does not prove a faster interaction. Compression cannot repair slow origin processing, oversized images, excessive JavaScript, or a cache configuration that delivers the wrong variant. The common failure mode is compressing already-compressed media or judging compression from an uncompressed local file.