Loki: resource frontend browser cache (#110488)

feat: allow frontend to set browser cache for config endpoint
This commit is contained in:
Galen Kistler 2025-09-26 07:18:20 -05:00 committed by GitHub
parent 0163d1888e
commit a8bff45256
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -162,6 +162,13 @@ func callResource(ctx context.Context, req *backend.CallResourceRequest, sender
respHeaders := map[string][]string{
"content-type": {"application/json"},
}
// frontend sets the X-Grafana-Cache with the desired response cache control value
if len(req.GetHTTPHeaders().Get("X-Grafana-Cache")) > 0 {
respHeaders["X-Grafana-Cache"] = []string{"y"}
respHeaders["Cache-Control"] = []string{req.GetHTTPHeaders().Get("X-Grafana-Cache")}
}
if rawLokiResponse.Encoding != "" {
respHeaders["content-encoding"] = []string{rawLokiResponse.Encoding}
}