From: Olivier Houchard Date: Wed, 25 Nov 2026 17:57:22 +0000 (+0100) Subject: BUG/MEDIUM: cache: build the secondary key on an unusable first entry X-Git-Tag: v3.5-dev14~11 X-Git-Url: https://git.kaiwu.me/http/%22../static/gitweb.js?a=commitdiff_plain;h=c286215b5ab5589b08b7814274d4ea529d5692d0;p=haproxy.git BUG/MEDIUM: cache: build the secondary key on an unusable first entry With "process-vary on", http_action_req_cache_use() returns without building the secondary key when the first entry found for the primary key cannot be used, because it is expired, stripped to its early hints or still being stored. The response is then not stored if it has a Vary header, since the transaction has no secondary key, and the expired entry is not removed either. So once the first variant of a resource has expired, this resource is not cached anymore, until that entry gets evicted. Let's build the secondary key in this case too, as was done before commit 25fcee5b0 ("MEDIUM: cache: emit early hints if configured to do so"), where an expired first entry was not returned by get_entry(). This was introduced in 3.5-dev3, no backport is needed. --- diff --git a/src/cache.c b/src/cache.c index 13e51b3e5..8b390a830 100644 --- a/src/cache.c +++ b/src/cache.c @@ -2934,6 +2934,10 @@ enum act_return http_action_req_cache_use(struct act_rule *rule, struct proxy *p * can't use the cache's entry and must forward the request to * the server. */ if (!res) { + /* the secondary key is needed to store the response */ + if ((cache->flags & CACHE_CF_VARY_PROCESSING) && + !(txn->flags & TX_CACHE_HAS_SEC_KEY)) + http_request_prebuild_full_secondary_key(s); return ACT_RET_CONT; } else if (!(res->flags & CACHE_EF_COMPLETE) || (res->flags & CACHE_EF_STRIPPED)) { release_entry(cache_tree, res, 1);