fix(cache): skip embeddings in the response cache

Embeddings responses are large and rarely repeat. Each one was stored
for the cache TTL in the shared Redis. A burst of them raised memory
on the shared Dragonfly to its limit.

The cache now skips /v1/embeddings unless cache.cacheEmbeddings is
true. The default is false. Chat caching does not change.
This commit is contained in:
2026-10-28 20:34:48 +00:00
parent 52b5e60719
commit 6d3c8bf9b7
5 changed files with 94 additions and 3 deletions
+4 -1
View File
@@ -115,7 +115,9 @@ func buildResponseCache(cc CacheConfig, client *respClient, logf, warnf, errorf
logf("cache: enabled but redis is not configured; response caching disabled")
return nil, nil
}
return newResponseCache(client, ttl, maxBody, logf, errorf), nil
c := newResponseCache(client, ttl, maxBody, logf, errorf)
c.embeddings = cc.CacheEmbeddings
return c, nil
}
// groupCacheEnabled resolves whether grp's requests are cacheable, given
@@ -229,6 +231,7 @@ type responseCache struct {
lastFailure time.Time
ttl time.Duration
maxBodyBytes int
embeddings bool // CacheConfig.CacheEmbeddings
logMu sync.Mutex
}