diff options
author | Klaus Post <klauspost@gmail.com> | 2021-06-18 10:49:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-18 11:49:49 -0600 |
commit | 69c914483d448cae05ebc4b658a331682532d3d3 (patch) | |
tree | d3e62d7f9e2d1fa2d2a4ab9b83d54c6b8fedd443 /modules/caddyhttp/encode/zstd | |
parent | 9d4ed3a3236df06e54c80c4f6633b66d68ad3673 (diff) |
encode: Tweak compression settings (#4215)
* Tweak compression settings
zstd: Limit window sizes to 128K to keep memory in control both server and client size.
zstd: Write 0 length frames. This may be needed for compatibility.
zstd: Create fewer encoders. Small memory improvement.
gzip: Allow -2 (Huffman only) and -3 (stateless) compression modes.
* Update modules/caddyhttp/encode/zstd/zstd.go
Update docs.
Co-authored-by: Francis Lavoie <lavofr@gmail.com>
Co-authored-by: Francis Lavoie <lavofr@gmail.com>
Diffstat (limited to 'modules/caddyhttp/encode/zstd')
-rw-r--r-- | modules/caddyhttp/encode/zstd/zstd.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/modules/caddyhttp/encode/zstd/zstd.go b/modules/caddyhttp/encode/zstd/zstd.go index 5182fc4..d2a638c 100644 --- a/modules/caddyhttp/encode/zstd/zstd.go +++ b/modules/caddyhttp/encode/zstd/zstd.go @@ -47,7 +47,10 @@ func (Zstd) AcceptEncoding() string { return "zstd" } // NewEncoder returns a new gzip writer. func (z Zstd) NewEncoder() encode.Encoder { - writer, _ := zstd.NewWriter(nil) + // The default of 8MB for the window is + // too large for many clients, so we limit + // it to 128K to lighten their load. + writer, _ := zstd.NewWriter(nil, zstd.WithWindowSize(128<<10), zstd.WithEncoderConcurrency(1), zstd.WithZeroFrames(true)) return writer } |