gzip_window
The gzip_window directive sets the size of the sliding window for gzip compression in NGINX.
Description
The gzip_window directive configures the maximum size of the sliding window used for the zlib compression algorithm when Gzip compression is enabled in NGINX. It specifies how much of the input data can be kept in memory when compressing a response. A larger window size can improve compression efficiency by allowing more data to be referenced when processing each byte of the output, leading to better compression ratios. However, it also increases the memory usage of the NGINX worker processes, which can be detrimental in environments with limited memory resources.
This directive accepts a single argument, which should be specified in bytes, meaning you might need to provide it as a numeric value without any suffix. When set, the directive enables the use of the specified window size for Gzip compression, enhancing the overall performance and efficiency of content delivery over HTTP. If not configured, a default setting will be applied, which may not leverage the potential of the Gzip algorithm fully, depending on the type of content being compressed and its size.
In practical terms, users should carefully consider their server's memory capabilities before increasing this value, particularly in high-load scenarios or when handling large responses, as over-allocation could lead to memory exhaustion and performance degradation.
Config Example
gzip on;
gzip_window 32k;
location / {
gzip_types text/plain text/css application/json;
# any other configurations
}Setting a very large window can lead to increased memory usage per connection, potentially exhausting available memory.
Not all clients may support varying levels of gzip compression, so testing client compatibility is essential after changes.