Commit c662df40 authored by Ahmad Sherif's avatar Ahmad Sherif Committed by Ahmad Sherif

Don't set Cache-Control headers for git archives

Rails already sets Cache-Control according to the project visibility.
Always setting the header value to `private` prevents us from doing
proper caching (e.g. at CDN level) for public projects.

Related to https://gitlab.com/gitlab-com/gl-infra/infrastructure/issues/6829
parent 3d35bee2
......@@ -166,7 +166,6 @@ func setArchiveHeaders(w http.ResponseWriter, format gitalypb.GetArchiveRequest_
w.Header().Set("Content-Type", "application/octet-stream")
}
w.Header().Set("Content-Transfer-Encoding", "binary")
w.Header().Set("Cache-Control", "private")
}
func prepareArchiveTempfile(dir string, prefix string) (*os.File, error) {
......
......@@ -67,13 +67,15 @@ func TestSetArchiveHeaders(t *testing.T) {
w.Header().Set("Content-Type", "test")
w.Header().Set("Content-Length", "test")
w.Header().Set("Content-Disposition", "test")
w.Header().Set("Cache-Control", "test")
// This should be preserved
w.Header().Set("Cache-Control", "public, max-age=3600")
setArchiveHeaders(w, testCase.in, "filename")
testhelper.AssertResponseWriterHeader(t, w, "Content-Type", testCase.out)
testhelper.AssertResponseWriterHeader(t, w, "Content-Length")
testhelper.AssertResponseWriterHeader(t, w, "Content-Disposition", `attachment; filename="filename"`)
testhelper.AssertResponseWriterHeader(t, w, "Cache-Control", "private")
testhelper.AssertResponseWriterHeader(t, w, "Cache-Control", "public, max-age=3600")
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment