• Compress
    • Configuration Examples
    • Notes

    Compress

    Compressing the Response before Sending it to the Client

    Compress

    The Compress middleware enables the gzip compression.

    Configuration Examples

    1. # Enable gzip compression
    2. labels:
    3. - "traefik.http.middlewares.test-compress.compress=true"
    1. # Enable gzip compression
    2. apiVersion: traefik.containo.us/v1alpha1
    3. kind: Middleware
    4. metadata:
    5. name: test-compress
    6. spec:
    7. compress: {}
    1. "labels": {
    2. "traefik.http.middlewares.test-compress.compress": "true"
    3. }
    1. # Enable gzip compression
    2. labels:
    3. - "traefik.http.middlewares.test-compress.compress=true"
    1. # Enable gzip compression
    2. [http.middlewares]
    3. [http.middlewares.test-compress.compress]
    1. # Enable gzip compression
    2. http:
    3. middlewares:
    4. test-compress:
    5. compress: {}

    Notes

    Responses are compressed when:

    • The response body is larger than 1400 bytes.
    • The Accept-Encoding request header contains gzip.
    • The response is not already compressed, i.e. the Content-Encoding response header is not already set.