Skip to content
/ gitea Public
forked from go-gitea/gitea

Commit

Permalink
Fix cache-control header clearing comment text when editing issue
Browse files Browse the repository at this point in the history
The no-store cache control added in go-gitea#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 go-gitea#22603
  • Loading branch information
brechtvl committed Jan 26, 2023
1 parent e8ac6a9 commit 790705b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/httpcache/httpcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 790705b

Please sign in to comment.