diff options
author | Brecht Van Lommel <brecht@blender.org> | 2023-02-01 22:28:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-01 15:28:06 -0600 |
commit | 1e0e79dcbfb21971ac4cd591585672517117d4f0 (patch) | |
tree | 457e9df22f6d0bcca0f61b1763f9e9feb8a00efd | |
parent | b6b8feb3dec19e7bc96bc583acf10c01afca3362 (diff) | |
download | gitea-1e0e79dcbfb21971ac4cd591585672517117d4f0.tar.gz gitea-1e0e79dcbfb21971ac4cd591585672517117d4f0.zip |
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
-rw-r--r-- | modules/httpcache/httpcache.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/modules/httpcache/httpcache.go b/modules/httpcache/httpcache.go index 1247a81fea..d7d9ce0b7e 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) |