unzstd_force
The `unzstd_force` directive specifies conditions under which zstd-decoding is forcibly applied to HTTP responses, enhancing compatibility with clients that do not support zstd encoding.
Description
The unzstd_force directive is utilized within the NGINX configuration to enforce the decompression of zstd-encoded responses, particularly for clients that lack native support for this encoding format. The directive accepts one or more string parameters, and if any of these values are provided (non-empty and not equal to "0"), it causes the server to attempt decompression of responses encoded with 'Content-Encoding: zstd'. This feature is especially valuable in environments where backward compatibility with older clients is critical, allowing them to receive data in a decompressed format while still benefiting from the storage and I/O efficiencies of zstd compression on the server side.
When implementing the unzstd_force directive, it is important to note that feedback from the server to the client relies on the existence of the 'Content-Encoding: zstd' header within the response. If this header is not present, the module refrains from attempting decompression, preventing unexpected behavior. Moreover, this directive can be placed within various NGINX contexts such as http, server, or location scopes, providing flexibility in configuration based on specific routing or server setup requirements.
Config Example
location / {
unzstd on;
unzstd_force "force_condition";
proxy_pass http://backend.com;
}Forcing decompression for unsupported clients may lead to increased server load due to additional processing required for decompression.
Ensure that the 'Content-Encoding: zstd' header is correctly set in responses to avoid discrepancies.
Using too many values in the unzstd_force directive can lead to complexity and potentially unintended consequences in request handling.