MINOR: cache: add config options for early hints support

Support for 103 early hints responses can now be enabled at the HTTP
cache level with "early-hints on" - defaults to off.
This commit is contained in:
Maxime Henrion 2026-05-28 16:41:02 -04:00 committed by Willy Tarreau
parent bbbd7909bc
commit f4da8e0299
2 changed files with 27 additions and 0 deletions

View file

@ -20243,6 +20243,17 @@ cache <name>
Declare a cache section, allocate a shared cache memory named <name>, the
size of cache is mandatory (see keyword "total-max-size" below).
early-hints <on/off>
Enable or disable support for HTTP 103 Early Hints responses (see RFC 8297).
When enabled, the cache remembers relevant "Link" response headers (with a
"rel" parameter of preload, preconnect, dns-prefetch, modulepreload or
prefetch) seen on cached responses. When a subsequent "cache-use" lookup
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).
max-age <seconds>
Define the maximum expiration duration. The expiration is set as the lowest
value between the s-maxage or max-age (in this order) directive in the

View file

@ -46,6 +46,7 @@
/* Flags for configuration. */
#define CACHE_CF_VARY_PROCESSING 0x00000001 /* manage Vary header (disabled by default) */
#define CACHE_CF_EARLY_HINTS 0x00000002 /* enable HTTP 103 Early Hints (disabled by default) */
static uint64_t cache_hash_seed = 0;
@ -2432,6 +2433,21 @@ int cfg_parse_cache(const char *file, int linenum, char **args, int kwm)
file, linenum, args[0]);
err_code |= ERR_WARN;
}
} else if (strcmp(args[0], "early-hints") == 0) {
if (alertif_too_many_args(1, file, linenum, args, &err_code)) {
err_code |= ERR_ABORT;
goto out;
}
if (strcmp(args[1], "on") == 0) {
tmp_cache_config->flags |= CACHE_CF_EARLY_HINTS;
} else if (strcmp(args[1], "off") == 0) {
tmp_cache_config->flags &= ~CACHE_CF_EARLY_HINTS;
} else {
ha_warning("parsing [%s:%d]: '%s' expects \"on\" or \"off\" (enable or disable HTTP 103 Early Hints support).\n",
file, linenum, args[0]);
err_code |= ERR_WARN;
}
} else if (strcmp(args[0], "max-secondary-entries") == 0) {
unsigned int max_sec_entries;
char *err;