mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-29 13:16:10 +01:00
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
This commit is contained in:
parent
b6b8feb3de
commit
1e0e79dcbf
|
@ -21,12 +21,12 @@ func AddCacheControlToHeader(h http.Header, maxAge time.Duration, additionalDire
|
||||||
|
|
||||||
if setting.IsProd {
|
if setting.IsProd {
|
||||||
if maxAge == 0 {
|
if maxAge == 0 {
|
||||||
directives = append(directives, "no-store")
|
directives = append(directives, "max-age=0", "private", "must-revalidate")
|
||||||
} else {
|
} else {
|
||||||
directives = append(directives, "private", "max-age="+strconv.Itoa(int(maxAge.Seconds())))
|
directives = append(directives, "private", "max-age="+strconv.Itoa(int(maxAge.Seconds())))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
directives = append(directives, "no-store")
|
directives = append(directives, "max-age=0", "private", "must-revalidate")
|
||||||
|
|
||||||
// to remind users they are using non-prod setting.
|
// to remind users they are using non-prod setting.
|
||||||
h.Add("X-Gitea-Debug", "RUN_MODE="+setting.RunMode)
|
h.Add("X-Gitea-Debug", "RUN_MODE="+setting.RunMode)
|
||||||
|
|
Loading…
Reference in a new issue