diff options
author | Vladimir Shushlin <v.shushlin@gmail.com> | 2021-12-14 17:26:30 +0300 |
---|---|---|
committer | Vladimir Shushlin <v.shushlin@gmail.com> | 2021-12-15 13:32:45 +0300 |
commit | 0cfd85f8edd8f52db96b72b9efb99f0183053536 (patch) | |
tree | 6df208bb47e6447d051cc9cc67eaa8a4388e7e2f | |
parent | 097c4c0aec8ddb0028ed8be8ed338d87020c5a9b (diff) |
feat: hide handling cache headers behind the faeture flag
vfsServing.ServeCompressedFile logic is quite comples,
and I'm afraid that we may handle something not the right way
So I want to hide this behind the feature flag before cutting the release
Changelog: fixed
-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 |