zstd_comp_level
The `zstd_comp_level` directive sets the compression level for Zstandard compression in NGINX.
Description
The zstd_comp_level directive is a configuration setting in the NGINX ngx_http_zstd_filter_module that determines the level of compression applied when compressing response data using the Zstandard (zstd) algorithm. This directive takes an integer argument which specifies the desired compression level where higher values result in greater compression at the cost of increased CPU usage. The levels typically range from 1 (fastest, least compression) to 22 (slowest, most compression), allowing users to fine-tune the balance between speed and compression efficiency according to their specific needs.
When enabled, the zstd_comp_level directive can be set within various contexts including http, server, and location. This flexibility allows administrators to define different compression levels for different parts of their server configurations. The effective compression level influences the size of the data sent over the network, which can enhance loading times for clients but may also impact server performance based on the selected level. It is important to ensure that the compression levels used are appropriate for the nature and size of the responses being sent.
Config Example
location / {
zstd on;
zstd_comp_level 3;
zstd_min_length 256;
proxy_pass http://backend;
}Using very high compression levels can increase CPU usage significantly, leading to reduced server performance.
Not specifying this directive may result in default compression levels that may not meet performance or size requirements.