diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2021-12-16 01:48:28 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2021-12-16 01:48:28 +0300 |
commit | d89774884db4a0ee1634e2fc5d4e93f96d5cbdbc (patch) | |
tree | 6df208bb47e6447d051cc9cc67eaa8a4388e7e2f | |
parent | 6926b549b4cf9bc53091977f9c6c4c69e1d41f17 (diff) | |
parent | 0cfd85f8edd8f52db96b72b9efb99f0183053536 (diff) |
Merge branch 'serve-with-cache-headers-ff' into 'master'
feat: hide handling cache headers behind the faeture flag
See merge request gitlab-org/gitlab-pages!645
-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 |