gzip_hash

The `gzip_hash` directive specifies the hash algorithm used for gzip compression settings in NGINX.

Syntaxgzip_hash { algorithm | md5 | sha1 | crc32 };
Defaultmd5
Contexthttp, server, location
Arguments1

Description

The gzip_hash directive is part of NGINX's HTTP Core module, which controls how NGINX handles gzip compression of HTTP responses. By defining the hash method, it optimizes the storage and retrieval of gzip parameters for cached content, allowing better performance under high load.

This directive can be configured with various hash algorithms such as md5, sha1, or crc32, allowing users to tailor the responsiveness and resource usage of gzip compression based on their server's capabilities and the expected type of content. The selection of the hash method could influence both the performance and size of the stored gzip flags, thereby impacting the overall memory footprint. NGINX looks into the compression context and generates hash values from the configured parameters to ensure unique identifiers for compressed content based on the selected hash function.

The gzip_hash directive can be placed within the http, server, or location context, giving it flexibility in configuration. It's essential to note that choosing a more complex hash function can improve the uniqueness of entries but may consume additional CPU cycles, so it is advisable to consider the specific needs of your application and its expected load when configuring it.

Config Example

http {
    gzip on;
    gzip_hash sha1;
}

Ensure that the chosen hash algorithm is supported by your NGINX version.

Using a complex hash algorithm may increase CPU usage while providing marginal benefits in compression efficiency.

Changing the hash algorithm impacts how previously cached gzip responses are handled, potentially needing regeneration of those cached items.

← Back to all directives