fix(cache): honour X-Skip-Cache and Cache-Control no-cache

Clients sent X-Skip-Cache: true or Cache-Control: no-cache on reads
that gate money and quotas, but the proxy ignored both and answered
from its cache for up to CACHE_TTL seconds. A quota or overage setting
change therefore took effect late.

A request with either header now goes to the backend, is not stored
and does not join an identical request in flight.
This commit is contained in:
2026-11-18 02:40:46 +00:00
parent e5b47fc568
commit 8c5f229bbd
4 changed files with 108 additions and 2 deletions
+3 -1
View File
@@ -726,7 +726,9 @@ func performProxyRequest(c fiber.Ctx, proxyURL string) error {
// Check if request coalescing is enabled
rc := GetRequestCoalescer()
if rc != nil && cfg.RequestCoalescing.Enable {
// A cache-bypass read must not join an identical request already in flight:
// that one may have started before the write the caller needs to see.
if rc != nil && cfg.RequestCoalescing.Enable && !skipCacheRequested(c) {
// Use request coalescing to deduplicate identical concurrent requests
response, err := rc.Do(cacheKey, func() (*CoalescedResponse, error) {
// Execute the actual proxy request