Normalize Accept-Encoding via HAProxy for optimized Squid hit rate

gziphaproxysquid

Our website infrastructure uses HAProxy for load balancing, a Squid cluster for caching, and application data is on an IIS cluster.

We load balance HAProxy by URI to optimize the Squid hit-rate, but we know that Squid is holding different copies of each page based on the Accept-Encoding header passed to it by the browser, and so IE (gzip, deflate) will have a different copy of a cached page than Firefox (gzip,deflate) or Chrome (gzip,deflate,sdch).

We want to normalize the Accept-Encoding headers and I think the best place to do so would be in HAProxy. I'd appreciate it if someone could offer some ideas on how to accomplish this without breaking support for clients without gzip or deflate support.

Best Answer

Well, maybe you'd just want to replace "gzip,deflate,anything" with "gzip,deflate" ?

You could do it like this :

reqirep ^Accept-Encoding:\ gzip,[\ ]*deflate,.* Accept-Encoding:\ gzip,\ deflate

Also, if you're using a large squid farm, you may be interested in haproxy 1.4's consistent hashing. It avoid rebalancing everyone when you add or remove a server, so that server transitions are smoother.