Compression reduces text payload size, while encoding cost and cache variants determine whether the delivery setup stays efficient.

Negotiate at the edge

Cloud CDN applies Brotli or Gzip for eligible text. Origin can send uncompressed. Clients get the encoding they ask for.

The delivery model

How it works

Brotli vs Gzip

  1. 01NegotiateRead the client’s supported content encodings.
  2. 02EncodeReturn a suitable compressed representation.
  3. 03CacheKeep encoding variants distinct.
Conceptual model for this configuration. The actual path depends on provider policy and application behavior.

Leave media alone

JPEG, WebP, MP4 and zip files are already compressed. Double compression wastes CPU and can enlarge the object.

Pair with hashed filenames

Compressed hashed assets can use long TTLs. You are not recomputing Brotli on every hit once the variant is cached.

APIs too

JSON bodies that pass through the edge are text. Brotli helps APIs as well as pages.

Validate before production

Request the same text resource with br, gzip, and identity acceptance. Inspect Content-Encoding and Vary, and compare decoded bodies. Benchmark bytes and CPU on representative files rather than assuming one fixed compression saving.

  • Record the configuration and expected result before changing traffic.
  • Keep evidence of the test and a working rollback for the previous behavior.

Sources & further reading