zstd_min_length
The `zstd_min_length` directive sets the minimum response body size that will be compressed using Zstandard compression.
Description
The zstd_min_length directive specifies the minimum size in bytes a response body must have in order to be eligible for Zstandard compression. This directive can be set at the http, server, or location context level. It is particularly useful to avoid unnecessary overhead of compressing small responses which may not gain significant benefits from compression. For example, if set to 256, any response body smaller than this size will not be compressed, thus possibly improving response times for such small resources.
When determining whether to compress a response, the module checks the zstd_min_length value before applying the Zstandard compression algorithm. If the response body size is equal to or exceeds this length, the compression will be executed; otherwise, the response will be sent uncompressed. This setting plays a crucial role in tuning the server's performance regarding how it handles various content sizes, especially in environments where both small and large responses are common.
Config Example
location / {
zstd on;
zstd_min_length 256; # Compress responses only if body is 256 bytes or larger
}Setting zstd_min_length too high may prevent the compression of useful small responses, leading to larger payload sizes;
Be sure to define zstd as on, otherwise this directive will have no effect;
Default behavior is to compress all responses unless this directive is used to limit compression based on response size.