mod_deflate (since lighttpd 1.4.42) enables output compression of responses. (Content-Encoding)
Output compression reduces the network load and can improve the overall throughput of the webserver. All major http-clients support compression by announcing it in the Accept-Encoding header. This is used to negotiate the most suitable compression method. We support deflate, gzip, bzip2, and brotli. (brotli support since 1.4.56)
deflate (RFC1950, RFC1951) and gzip (RFC1952) depend on zlib while bzip2 depends on libbzip2. bzip2 is only supported by lynx and some other console text-browsers. brotli (RFC7932) is supported in most popular browsers.
Since lighttpd 1.4.56, mod_deflate subsumes and replaces mod_compress. mod_deflate can compress static and dynamic responses, while mod_compress could compress only static files.
deflate.max-compress-size is the largest response size that will be compressed.
deflate.min-compress-size is the smallest response size that will be compressed.
deflate.compression-level is compression level or quality tuning for the underlying compressor.
man gzip (1..9);
man bzip2 (1..9);
man -s 3brotli encode.h (0..11)
deflate.output-buffer-size is a per connection buffer for compressed output, it can
help decrease the response size (fewer chunks to encode). If it is set to
zero, a shared buffer will be used.
deflate.work-block-size is the number of kilobytes to compress at one time, it allows
the webserver to do other work (network I/O) in between compression.
deflate.max-loadavg is max system loadavg before bypassing compression (since 1.4.43)
deflate.cache-dir (since 1.4.56) is the location under which to store cache of compressed files. Cleaning the cache is left to the user. A cron job deleting files older than
10 days could do it:
find /path/to/compress/cache -type f -mtime +10 | xargs -r rm
mod_deflate currently does not stream compressed content in chunks. This affects very large dynamic responses, or dynamic responses sent in chunks with large time lapses between chunks. If the entire response is not ready when the response header is sent, mod_deflate does not process the response. (e.g. dynamic response from backend and
server.stream-response-body is set > 0) While mod_deflate does not handle this use case, the backend producing the streaming response is able to apply an appropriate Content-Encoding itself (instead of mod_deflate).
deflate.cache-dir, if set, contains cached output of static files, but does not cache dynamic responses. (dynamic responses, if eligible, are still compressed by mod_deflate before the response is sent to the client.)
mod_deflate must be listed after mod_setenv in
server.modules if mod_setenv might be used to force setting "Content-Encoding" response header.