fix: disable cache for 302 redirect (close #2216)

pull/2223/head
Noah Hsu 2022-11-05 15:54:51 +08:00
parent f0a533a77a
commit 18cd45d257
2 changed files with 2 additions and 0 deletions

View File

@ -37,6 +37,7 @@ func Down(c *gin.Context) {
return return
} }
c.Header("Referrer-Policy", "no-referrer") c.Header("Referrer-Policy", "no-referrer")
c.Header("Cache-Control", "max-age=0, no-cache, no-store, must-revalidate")
c.Redirect(302, link.URL) c.Redirect(302, link.URL)
} }
} }

View File

@ -232,6 +232,7 @@ func (h *Handler) handleGetHeadPost(w http.ResponseWriter, r *http.Request) (sta
common.GetApiUrl(r), common.GetApiUrl(r),
utils.EncodePath(reqPath, true), utils.EncodePath(reqPath, true),
sign.Sign(path.Base(reqPath))) sign.Sign(path.Base(reqPath)))
w.Header().Set("Cache-Control", "max-age=0, no-cache, no-store, must-revalidate")
http.Redirect(w, r, u, 302) http.Redirect(w, r, u, 302)
} else { } else {
link, _, err := fs.Link(ctx, reqPath, model.LinkArgs{IP: utils.ClientIP(r)}) link, _, err := fs.Link(ctx, reqPath, model.LinkArgs{IP: utils.ClientIP(r)})