MINOR: cache: allow opting out of early hints at the rule level

A "cache-use" directive can now specify the "no-early-hints" keyword
to suppress 103 Early Hints emission for matching requests, when used
with a cache that has the "early-hints" setting enabled.
This commit is contained in:
Maxime Henrion 2026-06-26 16:45:23 -04:00 committed by Willy Tarreau
parent 6f8c422252
commit 954614c03a
2 changed files with 20 additions and 4 deletions

View file

@ -15418,7 +15418,7 @@ cache-store <name>
See section 6.2 about cache setup.
cache-use <name>
cache-use <name> [no-early-hints]
Usable in: QUIC Ini| TCP RqCon| RqSes| RqCnt| RsCnt| HTTP Req| Res| Aft
- | - | - | - | - | X | - | -
@ -15427,6 +15427,12 @@ cache-use <name>
use a condition for both storage and delivering that's a good idea to put it
after this one.
When the named cache has "early-hints" enabled, lookups handled by this
rule may emit a 103 Early Hints response if the requested URL has known
"Link" hints in the cache. The optional "no-early-hints" keyword
suppresses 103 emission for requests handled by this rule, regardless of
the cache-level setting.
See section 6.2 about cache setup.
@ -20251,8 +20257,9 @@ early-hints <on/off>
cannot serve the full response from the cache but the URL's "Link" hints
are still known, the cache emits a 103 Early Hints response carrying those
hints before forwarding the request to the backend, giving the client a
head start on fetching subresources while the backend produces the body. The
default value is off (disabled).
head start on fetching subresources while the backend produces the body.
Individual "cache-use" rules may opt out of this behavior with the
"no-early-hints" keyword. The default value is off (disabled).
max-age <seconds>
Define the maximum expiration duration. The expiration is set as the lowest

View file

@ -2544,7 +2544,8 @@ enum act_return http_action_req_cache_use(struct act_rule *rule, struct proxy *p
shctx_row_detach(shctx, entry_block);
detached = 1;
} else {
if ((cache->flags & CACHE_CF_EARLY_HINTS) &&
/* p[1] holds the "no-early-hints" opt-out set by parse_cache_use(). */
if ((cache->flags & CACHE_CF_EARLY_HINTS) && !rule->arg.act.p[1] &&
(res->flags & (CACHE_EF_STRIPPED | CACHE_EF_COMPLETE))) {
/* The emitted hints are best-effort and may not exactly
* match the response finally served: with Vary they may
@ -2715,6 +2716,14 @@ enum act_parse_ret parse_cache_use(const char **args, int *orig_arg, struct prox
return ACT_RET_PRS_ERR;
(*orig_arg)++;
/* Stash the "no-early-hints" opt-out in p[1], read back by
* http_action_req_cache_use() to skip 103 emission. */
if (*args[*orig_arg] && strcmp(args[*orig_arg], "no-early-hints") == 0) {
rule->arg.act.p[1] = (void *)(uintptr_t)1;
(*orig_arg)++;
}
return ACT_RET_PRS_OK;
}