unbrotli_force
The `unbrotli_force` directive controls the forced decompression of Brotli-encoded responses regardless of client support.
Description
The unbrotli_force directive in NGINX is part of the ngx_unbrotli filter module, which is responsible for decompressing responses that have been encoded using the Brotli compression algorithm. When this directive is enabled by setting it to on, it forces the server to decompress all Brotli-encoded responses, bypassing the usual check for the client's Accept-Encoding header, which indicates its ability to handle Brotli. This means that even clients that state they support Brotli will receive the decompressed content, which might be useful in specific cases where uncompressed data is required regardless of the client's capabilities.
This directive can be configured in various contexts, including http, server, and location, making it versatile for different levels of configuration granularity. The default value of unbrotli_force is off, meaning that the server will only decompress Brotli responses for clients that do not acknowledge Brotli support. When used in conjunction with the unbrotli directive, which must be enabled for any decompressing to occur, this directive provides fine control over response handling based on Brotli encoding, benefiting a select audience that might require the original data without compression.
Config Example
location /assets/ {
unbrotli on;
unbrotli_force on;
unbrotli_buffers 32 4k;
}Forcing decompression may lead to increased bandwidth usage since all Brotli-encoded responses are sent uncompressed, regardless of client capability.
Use carefully in performance-sensitive environments as it may negatively impact response times for clients that support Brotli compression.
Ensure that brotli responses are appropriately handled by upstream services if they generate responses that are also Brotli encoded.