From bae726dba69c1034aa4ea540a5b8db838446a58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ask=20Bj=C3=B8rn=20Hansen?= Date: Thu, 14 Dec 2023 20:00:09 -0800 Subject: [PATCH] scores: handle IPs with no current history --- server/history.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/history.go b/server/history.go index 4a28fe9..ec8f6c7 100644 --- a/server/history.go +++ b/server/history.go @@ -226,7 +226,8 @@ func (srv *Server) historyJSON(ctx context.Context, c echo.Context, server ntpdb } } - if history.LogScores[len(history.LogScores)-1].Ts.After(time.Now().Add(-8 * time.Hour)) { + if len(history.LogScores) == 0 || + history.LogScores[len(history.LogScores)-1].Ts.After(time.Now().Add(-8*time.Hour)) { // cache for longer if data hasn't updated for a while c.Request().Header.Set("Cache-Control", "s-maxage=3600,max-age=1800") } else {