Skip to content

Enable compression in Traefik by default#3157

Open
shleeable wants to merge 5 commits into
fosrl:mainfrom
shleeable:patch-3
Open

Enable compression in Traefik by default#3157
shleeable wants to merge 5 commits into
fosrl:mainfrom
shleeable:patch-3

Conversation

@shleeable

@shleeable shleeable commented May 26, 2026

Copy link
Copy Markdown
Contributor

Community Contribution License Agreement

By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.

Description

Enable the compress middleware by default for all http requests. (defaults are fine supporting modern zstd and falls back to gzip)

FYI: This is what I am running on my Pangolin... and mostly exists for reference depending on what path the dev team wants to head.

Update: That 250ms to 200ms is a nice drop as well....

How to test?

@shleeable shleeable marked this pull request as ready for review May 26, 2026 15:26
@shleeable

shleeable commented May 26, 2026

Copy link
Copy Markdown
Contributor Author

nginx with compression (gzip)
image

pangolin traefik without compression
image

pangolin traefik with compression (zstd)
image
image

@shleeable shleeable closed this May 26, 2026
@shleeable shleeable changed the title Enable compression in Traefik Enable compression in Traefik by default May 27, 2026
@shleeable shleeable reopened this May 27, 2026
@v1rusnl

v1rusnl commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Using Traefik's compression middleware with an empty configuration enables gzip/zstd/brotli compression for almost all content types, because Traefik's compress middleware works on a blacklist model unless e.g. Caddy.

Without excludedContentTypes, Traefik will attempt to compress:
Images - already compressed
Video segments - already compressed -> compression wastes CPU and can break range-requests and seeking
Audio - already compressed -> same issue as video
WOFF/WOFF2 fonts - already compressed

For each request to a non-compressible asset:

  • Proxy CPU is wasted running the compression algorithm
  • Client CPU is wasted decompressing for no benefit
  • Latency increases because the proxy may buffer the response before sending
  • Streaming breaks or stutters, flushInterval and range-requests interact badly with on-the-fly compression
  • File size barely changes or grows slightly due to compression headers

Therefor I run it like this:

http:
  middlewares:
    compress:
      compress:
        excludedContentTypes:
          - image/jpeg
          - image/png
          - image/webp
          - image/avif
          - video/*
          - audio/*
          - font/woff
          - font/woff2
          - application/zip
          - application/gzip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants