Private
Public Access
1
0

adjust cache-control for history api
All checks were successful
continuous-integration/drone/push Build is passing

it seems like there's a bug in the data calculations so many
servers get the too long maximum cache time; make it shorter
while we debug
This commit is contained in:
2025-06-27 17:48:40 +08:00
parent 087d253d90
commit 42ce22e83e

View File

@@ -399,12 +399,12 @@ func setHistoryCacheControl(c echo.Context, history *logscores.LogScoreHistory)
// cache for longer if data hasn't updated for a while; or we didn't // cache for longer if data hasn't updated for a while; or we didn't
// find any. // find any.
(time.Now().Add(-8 * time.Hour).After(history.LogScores[len(history.LogScores)-1].Ts)) { (time.Now().Add(-8 * time.Hour).After(history.LogScores[len(history.LogScores)-1].Ts)) {
hdr.Set("Cache-Control", "s-maxage=3600,max-age=1800") hdr.Set("Cache-Control", "s-maxage=260,max-age=360")
} else { } else {
if len(history.LogScores) == 1 { if len(history.LogScores) == 1 {
hdr.Set("Cache-Control", "s-maxage=60,max-age=35") hdr.Set("Cache-Control", "s-maxage=60,max-age=35")
} else { } else {
hdr.Set("Cache-Control", "s-maxage=240,max-age=120") hdr.Set("Cache-Control", "s-maxage=90,max-age=120")
} }
} }
} }