Skip to content

Commit

Permalink
satellite/console: cache /daily-usage and /usage-report endpoint resp…
Browse files Browse the repository at this point in the history
…onses for 1 hour

Cache those endpoint responses as they shouldn't change within one hour.

Issue:
storj/storj-private#567

Change-Id: I7baf449dd4a3dd1ecfa28a78b11081c9f3059ec6
  • Loading branch information
VitaliiShpital authored and Storj Robot committed Jan 23, 2024
1 parent e211742 commit 84fd22d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions satellite/console/consoleweb/consoleapi/usagelimits.go
Expand Up @@ -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()
}

Expand Down Expand Up @@ -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)))
Expand Down

0 comments on commit 84fd22d

Please sign in to comment.