Hi Olivier, On Mon, Mar 31, 2025 at 10:01:13AM +0200, Olivier D wrote: > Hello there ! > > I developed a lua action for HAProxy (v3.1) that returns a full http > response without any backend. > For this I'm using txn:done{}. > It's working great, with great performances too (+30k/sec queries handled). > But responses are not compressed, and it seems lua responses are not > transiting through HAProxy compression module. > Is it expected behaviour, and if so, How can I compress my responses ? It > seems zlib lua package is not available in official haproxy images so I > cannot compress it myself directly in LUA (or maybe I'm missing something, > I'm not a lua guy).
I don't see a good reason for Lua responses not being compressed. There are multiple reasons for a response not being compressed, among which the following (copy-pasted from the doc): Compression is disabled when: * the request does not advertise a supported compression algorithm in the "Accept-Encoding" header * the response message is not HTTP/1.1 or above * HTTP status code is not one of 200, 201, 202, or 203 * response contain neither a "Content-Length" header nor a "Transfer-Encoding" whose last value is "chunked" * response contains a "Content-Type" header whose first value starts with "multipart" * the response contains the "no-transform" value in the "Cache-control" header * User-Agent matches "Mozilla/4" unless it is MSIE 6 with XP SP2, or MSIE 7 and later * The response contains a "Content-Encoding" header, indicating that the response is already compressed (see compression offload) * The response contains an invalid "ETag" header or multiple ETag headers * The payload size is smaller than the minimum size (see compression minsize-res) For example have you tried with a content-length header to see if that changes anything ? Note that I'm not sure what happens in case we want chunking since the Lua code will obviously not emit chunks by itself. Regards, Willy