zstd
The `zstd` directive enables or disables Zstandard compression for HTTP responses in NGINX.
Description
The zstd directive is part of the NGINX module for Zstandard compression, which allows for efficient data compression using the Zstandard algorithm. By enabling this directive at the http, server, or location context, NGINX can process responses with Zstandard compression, effectively reducing response sizes and enhancing transmission speed over networks. Users can toggle compression on or off using this directive to suit their application needs.
Additionally, the Zstandard compression can be fine-tuned with related directives such as zstd_comp_level which adjusts the compression level, and zstd_min_length which specifies the minimum size of response to be compressed. This flexibility enables administrators to optimize both performance and resource usage, contributing to more efficient server operations. It is important to ensure that clients are capable of handling Zstandard compressed data when enabling this feature to avoid compatibility issues.
When using the zstd directive, it may also be beneficial to consider the zstd_dict_file directive for dictionary compression, which can improve compression ratios under certain conditions. However, users should be aware of the limitations regarding dictionary usage, as synchronization between client and server must be ensured to avoid inconsistency in decompression capabilities.
Config Example
location / {
zstd on;
zstd_min_length 256;
zstd_comp_level 3;
proxy_pass http://foo.com;
}Clients must support Zstandard decompression; otherwise, they may not understand the compressed responses.
Ensure that the Zstandard library is properly linked, as missing dependencies can cause runtime issues.
Compression may not yield significant benefits for very small responses; adjust min_length accordingly.