Skip to main content

Gzip Compression Configuration

The gzip plugin compresses eligible HTTP responses for clients that advertise gzip support, reducing response size on selected routes and services. Configuration covers plugin parameters.

Parameters​

See plugin common configurations for configuration options available to all plugins.

  • types

    array[string] | string

    default: ["text/html"]

    valid value:

    one or more nonempty MIME types, or *

    Response MIME types eligible for compression. Set to * to allow any MIME type.

    The response must include Content-Type. Parameters such as charset are ignored when matching a configured type.

  • min_length

    integer

    default: 20

    valid value:

    greater than or equal to 1

    Minimum response Content-Length, in bytes, eligible for compression. The plugin skips this check when the response does not include a numeric Content-Length.

  • comp_level

    integer

    default: 1

    valid value:

    between 1 and 9 inclusive

    Gzip compression level. Higher values can reduce response size further but require more CPU.

  • http_version

    number

    default: 1.1

    valid value:

    1.0 or 1.1

    Minimum client HTTP version eligible for compression.

  • buffers

    object

    default: {"number":32,"size":4096}


    Memory buffers used while compressing a response.

    • number

      integer

      default: 32

      valid value:

      greater than or equal to 1

      Number of compression buffers.

    • size

      integer

      default: 4096

      valid value:

      greater than or equal to 1

      Size of each compression buffer in bytes.

      In API7 Gateway 3.9.23 and APISIX 3.19.0, keep the default size. Support for smaller custom buffers was corrected in API7 Gateway 3.10.10 and APISIX 3.20.0.

  • vary

    boolean

    default: false


    If true, append Accept-Encoding to the Vary response header after the configured type, length, and HTTP-version checks pass, including when NGINX does not compress the response for the current client.