Skip to content

Commit 1e0e79d

Browse files
authored
Fix cache-control header clearing comment text when editing issue (#22604)
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 avoids 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 reloaded and lose the unsubmitted comment. Fixes #22603
1 parent b6b8feb commit 1e0e79d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

modules/httpcache/httpcache.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ func AddCacheControlToHeader(h http.Header, maxAge time.Duration, additionalDire
2121

2222
if setting.IsProd {
2323
if maxAge == 0 {
24-
directives = append(directives, "no-store")
24+
directives = append(directives, "max-age=0", "private", "must-revalidate")
2525
} else {
2626
directives = append(directives, "private", "max-age="+strconv.Itoa(int(maxAge.Seconds())))
2727
}
2828
} else {
29-
directives = append(directives, "no-store")
29+
directives = append(directives, "max-age=0", "private", "must-revalidate")
3030

3131
// to remind users they are using non-prod setting.
3232
h.Add("X-Gitea-Debug", "RUN_MODE="+setting.RunMode)

0 commit comments

Comments
 (0)