unzstd
The `unzstd` directive enables or disables the decompression of Zstandard-compressed responses for clients that do not support Zstandard encoding.
Description
The unzstd directive is a crucial feature of the NGINX ngx_http_unzstd_filter_module, designed to facilitate compatibility for clients that cannot handle Zstandard (Zstd) compression. When enabled, NGINX will automatically decompress responses that are sent with the Content-Encoding: zstd header. This is especially important for web clients that only support legacy compression formats, thus ensuring they can correctly receive and utilize web content compressed with Zstd.
An essential aspect of this directive is its flag parameter, which can be set to either on or off. Setting unzstd to on instructs NGINX to process incoming requests and responses, looking specifically for those marked as Zstd-compressed. If such a response is detected, it will be decompressed before being transmitted back to the client, allowing seamless access to the resource without the client needing inherent Zstd support. Conversely, if set to off, the module will refrain from any decompression operations, potentially leading to clients receiving compressed data they cannot decode.
This directive can be specified at different levels within NGINX configuration, specifically in http, server, or location blocks, providing flexibility in enabling decompression for specific contexts based on application needs. For comprehensive performance and resource management, it is coupled with two additional directives: unzstd_force, to conditionally enforce decompression, and unzstd_buffers, to control the buffer capacity used during decompression operations. This not only enables efficient data handling but also aids in optimizing server resource utilization.
Config Example
server {
listen 127.0.0.1:8080;
server_name localhost;
location / {
# Enable Zstd decompression for clients that do not support Zstd compression
unzstd on;
proxy_pass http://foo.com;
}
}Ensure that the Zstandard library is properly installed and configured, as the directive relies on external dependencies.
Be cautious with clients that do support Zstd; enabling decompression for all clients might lead to performance drawbacks if unnecessary.
This module is experimental, and improper configuration may lead to unexpected results, such as needing to disable it temporarily.