summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/caddyhttp/encode/gzip/gzip.go9
-rw-r--r--modules/caddyhttp/encode/zstd/zstd.go5
2 files changed, 8 insertions, 6 deletions
diff --git a/modules/caddyhttp/encode/gzip/gzip.go b/modules/caddyhttp/encode/gzip/gzip.go
index 8215b3f..0212583 100644
--- a/modules/caddyhttp/encode/gzip/gzip.go
+++ b/modules/caddyhttp/encode/gzip/gzip.go
@@ -15,7 +15,6 @@
package caddygzip
import (
- "compress/flate"
"fmt"
"strconv"
@@ -68,11 +67,11 @@ func (g *Gzip) Provision(ctx caddy.Context) error {
// Validate validates g's configuration.
func (g Gzip) Validate() error {
- if g.Level < flate.NoCompression {
- return fmt.Errorf("quality too low; must be >= %d", flate.NoCompression)
+ if g.Level < gzip.StatelessCompression {
+ return fmt.Errorf("quality too low; must be >= %d", gzip.StatelessCompression)
}
- if g.Level > flate.BestCompression {
- return fmt.Errorf("quality too high; must be <= %d", flate.BestCompression)
+ if g.Level > gzip.BestCompression {
+ return fmt.Errorf("quality too high; must be <= %d", gzip.BestCompression)
}
return nil
}
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
}