RECIPE

gzip / brotli response compression

Reduce transfer size by 70–90% with zero code changes.

Overview

Vercel Edge and Node runtimes automatically compress eligible responses when the client sends an Accept-Encoding header. Brotli is preferred for modern browsers; gzip serves as the universal fallback. No middleware or config required.

Eligibility

  • Response body exceeds 1 KB (Vercel default threshold).
  • Content-Type is text-based: HTML, CSS, JS, JSON, SVG, XML, WASM.
  • Response is not already compressed or streamed with Transfer-Encoding: chunked.

Verification

curl -s -H "Accept-Encoding: br" \
  https://getnimbus.net -o /dev/null \
  -w "%{size_download}"

Compare with and without the header. A 10× reduction is typical for uncompressed HTML payloads.

Opt-out

Set the Content-Encoding header manually in a route handler or middleware to bypass automatic compression. Useful when serving pre-compressed assets from an origin.