diff options
-rw-r--r-- | internal/feature/feature.go | 6 | ||||
-rw-r--r-- | internal/serving/disk/reader.go | 7 |
2 files changed, 12 insertions, 1 deletions
diff --git a/internal/feature/feature.go b/internal/feature/feature.go index 0a29f4a4..68c27e40 100644 --- a/internal/feature/feature.go +++ b/internal/feature/feature.go @@ -19,6 +19,12 @@ var RedirectsPlaceholders = Feature{ EnvVariable: "FF_ENABLE_PLACEHOLDERS", } +// HandleCacheHeaders enables handling cache headers when serving from compressed ZIP archives +// TODO: enable and remove https://gitlab.com/gitlab-org/gitlab-pages/-/issues/672 +var HandleCacheHeaders = Feature{ + EnvVariable: "FF_HANDLE_CACHE_HEADERS", +} + // Enabled reads the environment variable responsible for the feature flag // if FF is disabled by default, the environment variable needs to be "true" to explicitly enable it // if FF is enabled by default, variable needs to be "false" to explicitly disable it diff --git a/internal/serving/disk/reader.go b/internal/serving/disk/reader.go index 2aeeeb27..ec97b128 100644 --- a/internal/serving/disk/reader.go +++ b/internal/serving/disk/reader.go @@ -14,6 +14,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "gitlab.com/gitlab-org/labkit/errortracking" + "gitlab.com/gitlab-org/gitlab-pages/internal/feature" "gitlab.com/gitlab-org/gitlab-pages/internal/httperrors" "gitlab.com/gitlab-org/gitlab-pages/internal/logging" "gitlab.com/gitlab-org/gitlab-pages/internal/redirects" @@ -231,7 +232,11 @@ func (reader *Reader) serveFile(ctx context.Context, w http.ResponseWriter, r *h http.ServeContent(w, r, origPath, fi.ModTime(), rs) } else { w.Header().Set("Content-Length", strconv.FormatInt(fi.Size(), 10)) - vfsServing.ServeCompressedFile(w, r, fi.ModTime(), file) + if feature.HandleCacheHeaders.Enabled() { + vfsServing.ServeCompressedFile(w, r, fi.ModTime(), file) + } else { + io.Copy(w, file) + } } return true |