From: Olivier Houchard Date: Thu, 3 Dec 2026 10:30:40 +0000 (+0100) Subject: BUG/MEDIUM: cache: do not store unused HTX blocks with the headers X-Git-Url: https://git.kaiwu.me/web/%7Bsubstring-before(@doc,%20'.xml')%7D.html?a=commitdiff_plain;h=5f19999d51c9485a87091a375c83ab032da7c508;p=haproxy.git BUG/MEDIUM: cache: do not store unused HTX blocks with the headers When a response is stored, http_action_store_cache() copies all the blocks of the headers, including the unused ones left by a removed header, such as after "http-response del-header" or "set-header" on a header which is not the last one. When the object is served, the applet tries to add this empty block again, which htx_add_blk() refuses since commit 58ce50527 ("MINOR: htx: never create, leave nor accept an empty HTX block"), so each cache hit ends with a 500. Skip the unused blocks when storing the headers. This can be tested with "http-response del-header X-Test" before "http-response cache-store", and a server sending X-Test followed by another header: the second request for the same URL gets a 500. This should fix github issue #3616. It must be backported to 3.5. --- diff --git a/src/cache.c b/src/cache.c index 8b390a830..525c1b3c1 100644 --- a/src/cache.c +++ b/src/cache.c @@ -1883,6 +1883,9 @@ enum act_return http_action_store_cache(struct act_rule *rule, struct proxy *px, uint32_t sz = htx_get_blksz(blk); struct ist header_name = IST_NULL; + if (type == HTX_BLK_UNUSED) + continue; + /* The cache serves its copies with a freshly computed * Age, so the Age headers are not stored. They are left * in the response which is forwarded as-is.