From 84fd22d6d03982b7894ab497556ffe2c0f566134 Mon Sep 17 00:00:00 2001 From: Vitalii Date: Mon, 22 Jan 2024 15:13:47 +0200 Subject: [PATCH] satellite/console: cache /daily-usage and /usage-report endpoint responses for 1 hour Cache those endpoint responses as they shouldn't change within one hour. Issue: https://github.com/storj/storj-private/issues/567 Change-Id: I7baf449dd4a3dd1ecfa28a78b11081c9f3059ec6 --- satellite/console/consoleweb/consoleapi/usagelimits.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/satellite/console/consoleweb/consoleapi/usagelimits.go b/satellite/console/consoleweb/consoleapi/usagelimits.go index cb1f5029752f..3b92f3466dcc 100644 --- a/satellite/console/consoleweb/consoleapi/usagelimits.go +++ b/satellite/console/consoleweb/consoleapi/usagelimits.go @@ -180,6 +180,8 @@ func (ul *UsageLimits) UsageReport(w http.ResponseWriter, r *http.Request) { } } + w.Header().Set("Cache-Control", "public, max-age=3600") // Cache the same request for 1 hour. + wr.Flush() } @@ -227,6 +229,8 @@ func (ul *UsageLimits) DailyUsage(w http.ResponseWriter, r *http.Request) { return } + w.Header().Set("Cache-Control", "public, max-age=3600") // Cache the same request for 1 hour. + err = json.NewEncoder(w).Encode(dailyUsage) if err != nil { ul.log.Error("error encoding daily project usage", zap.Error(ErrUsageLimitsAPI.Wrap(err)))