Serve content with gzip encoding directly from our webserver. Improves performance re: #2167. Closes #2566

This commit is contained in:
Gabe Kangas
2023-01-08 23:38:54 -08:00
parent 70f0766186
commit 6951943afe
3 changed files with 72 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ import (
"net/http"
"time"
"github.com/nanmu42/gzip"
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
"golang.org/x/net/http2"
@@ -409,7 +410,7 @@ func Start() error {
server := &http.Server{
Addr: fmt.Sprintf("%s:%d", ip, port),
ReadHeaderTimeout: 4 * time.Second,
Handler: m,
Handler: gzip.DefaultHandler().WrapHandler(m),
}
log.Infof("Web server is listening on IP %s port %d.", ip, port)