Skip to main content

Module gzip

Module gzip 

Source
Expand description

The gzip node — compresses the response body with gzip when the client accepts it and the response matches the configured content types and minimum size. Port of APISIX’s gzip plugin (response-phase: place after upstream, before client).

In APISIX the plugin only flips nginx’s gzip switches and nginx does the actual work — including checking the request’s Accept-Encoding header below APISIX. featherbit has no nginx underneath, so this node performs the Accept-Encoding check and the compression itself (via content_codec).

Deviations from APISIX:

  • http_version and buffers are not supported (nginx tuning knobs with no featherbit equivalent — responses are fully buffered).
  • min_length is compared against the actual buffered body length, not the upstream Content-Length header (which APISIX/nginx skip checking when absent).

Structs§

GzipPlugin
Compresses Context.response.body with gzip, sets content-encoding: gzip, and drops the stale content-length so the server layer recomputes it. Skipped (pure passthrough) when the client does not accept gzip, the response is already content-encoded, the content type does not match, or the body is shorter than min_length. This plugin never fails at execution time — a codec error logs a warning and leaves the response untouched.

Enums§

ContentTypes 🔒
The types config: either any content type ("*") or an allowlist compared against the response content-type stripped of parameters.

Functions§

accepts_encoding 🔒
Whether the request’s Accept-Encoding allows token (e.g. "gzip", "br"): the token (or *) must be listed with a non-zero q value. A missing header means the client did not opt in — no compression.
response_already_encoded 🔒
Whether the response already carries a content-encoding other than identity. Compressing twice (or compressing opaque encoded bytes) is never wanted, whatever the encoding is — so an unknown value also counts as encoded.