From: Maxime Henrion Date: Thu, 28 May 2026 20:41:02 +0000 (-0400) Subject: MINOR: cache: add config options for early hints support X-Git-Url: http://git.kaiwu.me/ngx_http_auth_basic_module.html?a=commitdiff_plain;h=f4da8e0299b35b04a6b5d5cb215eeb359dd7c666;p=haproxy.git 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. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index b76c7541f..5e0625d5a 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -20243,6 +20243,17 @@ cache Declare a cache section, allocate a shared cache memory named , the size of cache is mandatory (see keyword "total-max-size" below). +early-hints + 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 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 diff --git a/src/cache.c b/src/cache.c index 5ede3472f..8a03a3021 100644 --- a/src/cache.c +++ b/src/cache.c @@ -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;