diff --git a/bskyweb/cmd/bskyweb/server.go b/bskyweb/cmd/bskyweb/server.go index a0b5d338d0..8d322fbe30 100644 --- a/bskyweb/cmd/bskyweb/server.go +++ b/bskyweb/cmd/bskyweb/server.go @@ -101,8 +101,19 @@ func serve(cctx *cli.Context) error { RedirectCode: http.StatusFound, })) - // enable gzip - e.Use(middleware.Gzip()) + // gzip transport compression for most responses. + // echo middleware is pretty naive, defaults to compressing every response, + // of any mimetype or size. we configure to skip some cases, but this is a + // pretty incomplete set of patterns. + e.Use(middleware.GzipWithConfig(middleware.GzipConfig{ + Skipper: func(c echo.Context) bool { + // don't compress PNG files, specifically + return strings.HasSuffix(c.Request().URL.Path, ".png") + }, + Level: -1, // default + // TODO: https://github.com/labstack/echo/pull/2267 + //MinLength: 1024, // default is "0" + })) // // configure routes