Skip to content

Commit 3fb47cd

Browse files
committed
feat(serverHandler/page): add response header Vary
Add respnse header `Vary: Content-Encoding` to ensure a page with different content-encoding will be cached separately.
1 parent 6e1dfac commit 3fb47cd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/serverHandler/page.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ func (h *handler) page(w http.ResponseWriter, r *http.Request, data *responseDat
7070
header.Set("Content-Type", "text/html; charset=utf-8")
7171
header.Set("Cache-Control", "public, max-age=0")
7272

73+
var vary string
74+
if r.ProtoMajor <= 1 {
75+
vary = "Accept-Encoding"
76+
} else {
77+
vary = "accept-encoding"
78+
}
79+
header.Set("Vary", vary)
80+
7381
updateTranslation(r, data)
7482

7583
if !needResponseBody(r.Method) {

0 commit comments

Comments
 (0)