summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--system/admin/config/config.go8
-rw-r--r--system/api/handlers.go6
2 files changed, 13 insertions, 1 deletions
diff --git a/system/admin/config/config.go b/system/admin/config/config.go
index ba12515..3605514 100644
--- a/system/admin/config/config.go
+++ b/system/admin/config/config.go
@@ -17,6 +17,7 @@ type Config struct {
ClientSecret string `json:"client_secret"`
Etag string `json:"etag"`
DisableCORS bool `json:"cors_disabled"`
+ DisableGZIP bool `json:"gzip_disabled"`
CacheInvalidate []string `json:"cache"`
}
@@ -83,6 +84,13 @@ func (c *Config) MarshalEditor() ([]byte, error) {
}),
},
editor.Field{
+ View: editor.Checkbox("DisableGZIP", c, map[string]string{
+ "label": "Disable GZIP (will increase server speed, but also bandwidth)",
+ }, map[string]string{
+ "true": "Disable",
+ }),
+ },
+ editor.Field{
View: editor.Checkbox("CacheInvalidate", c, map[string]string{
"label": "Invalidate cache on save",
}, map[string]string{
diff --git a/system/api/handlers.go b/system/api/handlers.go
index c3421f9..9292e15 100644
--- a/system/api/handlers.go
+++ b/system/api/handlers.go
@@ -323,6 +323,11 @@ func Record(next http.HandlerFunc) http.HandlerFunc {
// Gzip wraps a HandlerFunc to compress responses when possible
func Gzip(next http.HandlerFunc) http.HandlerFunc {
return http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ if db.ConfigCache("gzip_disabled").(bool) == true {
+ next.ServeHTTP(res, req)
+ return
+ }
+
// check if req header content-encoding supports gzip
if strings.Contains(req.Header.Get("Accept-Encoding"), "gzip") {
// gzip response data
@@ -330,7 +335,6 @@ func Gzip(next http.HandlerFunc) http.HandlerFunc {
gzres := gzipResponseWriter{res, gzip.NewWriter(res)}
next.ServeHTTP(gzres, req)
-
return
}