A3S Docs
A3S GatewayMiddleware

Compress

Mark responses eligible for proxy-layer br/gzip/deflate compression

Compress

compress marks eligible responses for compression. The proxy layer performs negotiation based on the client's Accept-Encoding.

Behavior

The request path passes through. On the response path, if Content-Encoding is not already set, the middleware inserts:

x-gateway-compress: eligible

The proxy layer prefers:

br > gzip > deflate > identity

Configuration

middlewares "compress" {
  type = "compress"
}
KeyTypeDefaultNotes
typestringrequiredMust be compress.

Current Limits

ACL configuration for compress ignores extra keys. The code defaults are minimum size 1024 bytes and compression level 6, but there are no ACL keys to change them.

Already-encoded responses are not marked again.

Notes

  • Compression helps text, JSON, HTML, CSS, JavaScript, SVG, and XML.
  • Avoid recompressing images, videos, zip files, or already-compressed payloads.
  • Watch CPU and tail latency on high-throughput routes.
middlewares = ["cors", "auth-jwt", "headers", "compress"]

On this page