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.
* 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);