For the complete documentation index, see llms.txt. This page is also available as Markdown.

zstd

The zstd middleware compresses HTTP response bodies when the client sends Accept-Encoding: zstd. It uses a pure Go implementation and does not require CGO. It does not decompress request bodies.

Availability

The RoadRunner v3 bundle includes the Zstd plugin. Add zstd to http.middleware to enable it.

Configuration

Add zstd to the middleware list in your existing HTTP configuration:

.rr.yaml
version: "3"

http:
  address: 127.0.0.1:8080
  middleware: [ "zstd" ]

The middleware does not require a separate configuration section. Eligible responses use Content-Encoding: zstd.

Put zstd before static or sendfile to compress their responses. See middleware order.

Compression behavior

  • Clients must request zstd explicitly with a nonzero quality value. Missing or unsupported encodings and zstd;q=0 leave the response uncompressed.

  • The default compression level is zstd.SpeedFastest. The implementation reuses encoders through a pool.

  • The normal minimum response size is 1,024 bytes. A flush can start compression below this limit.

  • The middleware skips HEAD requests, empty bodies, responses with an existing Content-Encoding or Content-Range, and content types excluded by the compression library.

  • The middleware adds Vary: Accept-Encoding. It removes the original Content-Length when it compresses a response.

  • The compression library does not change ETags by default.

The middleware supports OpenTelemetry header propagation when RoadRunner tracing is active.

Using gzip and zstd

The zstd middleware does not provide gzip fallback. The gzip middleware is a separate plugin.

Documentation

Last updated