BUG/MINOR: http-ana: let s-maxage override a null max-age whatever their order
A response carrying "Cache-Control: s-maxage=60, max-age=0" is not stored
in the cache, while "Cache-Control: max-age=0, s-maxage=60" is. Both mean
that private caches must not reuse the response while shared caches like
haproxy's may keep it for 60 seconds (RFC 9111#5.2.2.10), and the order
of the directives does not matter. Servers emitting the directives in
the first order, or as two separate Cache-Control headers in this order,
do not get their responses cached, which only affects performance.
http_check_response_for_cacheability() iterates over the Cache-Control
values. A "max-age=0" sets has_null_maxage and an "s-maxage" resets it,
so a "max-age=0" found after the "s-maxage" sets it again and the
response is finally considered as not cacheable.
The s-maxage directive is now recorded in its own variable, and the null
max-age only makes the response non-cacheable in the absence of s-maxage.
Note that "s-maxage=0" is handled earlier and does not count as an
s-maxage here, so it still makes the response non-cacheable.
The reg-test reg-tests/cache/smaxage_override.vtc checks the two orders
and the case of two headers. It fails without the fix.
This was introduced by commit
ca4fd7393 ("BUG/MINOR: cache: A 'max-age=0'
cache-control directive can be overriden by a s-maxage") in 2.9-dev2
which only handled the first order, so the fix may be backported to 3.0.