gzip_http_version

The gzip_http_version directive sets the minimum HTTP version required for gzip compression to be applied by NGINX.

Syntaxgzip_http_version version;
Default1.0
Contexthttp, server, location
Arguments1

Description

The gzip_http_version directive in NGINX determines the minimum HTTP version that a client must support in order to receive gzip-compressed responses. This setting is crucial for optimizing bandwidth and improving load times for clients that can handle compressed data. By configuring this directive, administrators ensure that only those clients that are capable of handling gzip responses will receive them, which aids in preventing incompatibility issues with older HTTP versions that may not support compression.

The parameter for this directive is a version string that can be either "1.0" or "1.1". If set to "1.0", gzip compression will only be enabled for clients using HTTP/1.0 or higher, while setting it to "1.1" allows gzip responses to clients only using HTTP/1.1 or higher. This granularity allows for better control over how compression is utilized according to client capabilities, ensuring that processing overhead for users of older protocols is avoided.

This directive can be placed within the http, server, or location context, making it flexible for different application scenarios throughout the server configurations. By considering the types of clients accessing the server, server admins can optimize compression behavior to enhance overall performance without introducing potential errors or complications.

Config Example

gzip on;
gzip_http_version 1.1;

Setting gzip_http_version to 1.1 may result in no compression for HTTP/1.0 clients, leading to potentially larger response sizes for these users.

Ensure gzip is enabled using the 'gzip on;' directive for this directive to take effect.

Compatibility with older clients should be considered when setting the HTTP version. Overly restricting this may alienate some users.

← Back to all directives