From 790705b84687cd2a6818a6ded7d2aaa9ce0ce0c4 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 26 Jan 2023 01:05:35 +0100 Subject: [PATCH] Fix cache-control header clearing comment text when editing issue The no-store cache control added in #20432 is causing form input to be cleared unnecessarily on page reload. Instead use max-age=0,private,must-revalidate which avoid this. This was particularly a problem when typing a long comment for an issue and then for example changing the label. The page would be reload and lose the unsubmitted comment. Fixes #22603 --- modules/httpcache/httpcache.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/httpcache/httpcache.go b/modules/httpcache/httpcache.go index 1247a81fea3cf..d7d9ce0b7ebf9 100644 --- a/modules/httpcache/httpcache.go +++ b/modules/httpcache/httpcache.go @@ -21,12 +21,12 @@ func AddCacheControlToHeader(h http.Header, maxAge time.Duration, additionalDire if setting.IsProd { if maxAge == 0 { - directives = append(directives, "no-store") + directives = append(directives, "max-age=0", "private", "must-revalidate") } else { directives = append(directives, "private", "max-age="+strconv.Itoa(int(maxAge.Seconds()))) } } else { - directives = append(directives, "no-store") + directives = append(directives, "max-age=0", "private", "must-revalidate") // to remind users they are using non-prod setting. h.Add("X-Gitea-Debug", "RUN_MODE="+setting.RunMode)