diff options
author | Vladimir Shushlin <v.shushlin@gmail.com> | 2021-12-24 17:54:11 +0300 |
---|---|---|
committer | Vladimir Shushlin <v.shushlin@gmail.com> | 2021-12-24 17:54:11 +0300 |
commit | d40af81155fdd50f7ea3b78249cc303b91acf63e (patch) | |
tree | c1f2026e278312a91529e5dce7b47d65cb5113f1 | |
parent | 5e488dfd5d56127c0721c974f89319a0aedec439 (diff) |
feat: enable Etag caching
Changelog: added
-rw-r--r-- | internal/feature/feature.go | 6 | ||||
-rw-r--r-- | internal/serving/disk/reader.go | 7 | ||||
-rw-r--r-- | test/acceptance/zip_test.go | 7 |
3 files changed, 1 insertions, 19 deletions
diff --git a/internal/feature/feature.go b/internal/feature/feature.go index 68c27e40..0a29f4a4 100644 --- a/internal/feature/feature.go +++ b/internal/feature/feature.go @@ -19,12 +19,6 @@ 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 b83425eb..5961d843 100644 --- a/internal/serving/disk/reader.go +++ b/internal/serving/disk/reader.go @@ -14,7 +14,6 @@ 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" @@ -235,11 +234,7 @@ 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)) - if feature.HandleCacheHeaders.Enabled() { - vfsServing.ServeCompressedFile(w, r, fi.ModTime(), file) - } else { - io.Copy(w, file) - } + vfsServing.ServeCompressedFile(w, r, fi.ModTime(), file) } return true diff --git a/test/acceptance/zip_test.go b/test/acceptance/zip_test.go index 42734d14..dcb831e7 100644 --- a/test/acceptance/zip_test.go +++ b/test/acceptance/zip_test.go @@ -10,14 +10,9 @@ import ( "time" "github.com/stretchr/testify/require" - - "gitlab.com/gitlab-org/gitlab-pages/internal/feature" - "gitlab.com/gitlab-org/gitlab-pages/internal/testhelpers" ) func TestZipServing(t *testing.T) { - testhelpers.StubFeatureFlagValue(t, feature.HandleCacheHeaders.EnvVariable, true) - runObjectStorage(t, "../../shared/pages/group/zip.gitlab.io/public.zip") RunPagesProcess(t, @@ -243,8 +238,6 @@ func TestZipServingCache(t *testing.T) { } func TestZipServingFromDisk(t *testing.T) { - testhelpers.StubFeatureFlagValue(t, feature.HandleCacheHeaders.EnvVariable, true) - RunPagesProcess(t, withListeners([]ListenSpec{httpListener}), ) |