Hello,
I'm looking into doing some normalization of headers in haproxy to improve
upstream cache-hit ratio.
Basically I have a set of Apache Traffic Server instances upstream, which uses
the Accept header for vary cache, but obviously since there's a huge amount of
various Accept headers that browsers or HTTP clients send, it results in fairly
bad hit ratios.
Therefore I'd like to normalize the accept headers to something relatively
simple.
The goal is to do something depending like, if the extension requested is jpeg,
jpg, png, gif, webp, then normalize the Accept header such as:
If Accept header contains image/webp AND image/avif == Set Accept
image/avif,image/webp
If Accept header contains image/webp AND NOT image/avif == Set Accept image/webp
If Accept header contains image/avif AND NOT image/webp == Set Accept image/avif
Do anyone have a recommendation how to reach this goal easily in haproxy? In
nginx for example, one can use a map:
map $http_accept $img_suffix {
default "none";
"~*avif" "avif";
"~*webp" "webp";
}
And then one can set the Accept header using $img_suffix result. Can one do
something similar in haproxy?
Thank you in advance!
Best Regards,
Lucas Rolff