gzip_disable
The gzip_disable directive controls disabling Gzip compression based on specified user-agent values.
Description
The gzip_disable directive allows administrators to manage when Gzip compression should not be applied, based on the user-agent of the request. This is particularly useful for optimizing performance by excluding certain clients from receiving compressed content that may not support it or that may negatively impact functionality, such as some crawlers or browsers.
The directive expects one or more arguments, which can be user-agent strings or regular expressions. If a match occurs between the user-agent of the incoming request and any of the specified arguments, Gzip compression is disabled for that request. The directive may be applied in the http, server, or location context, making it versatile for different scopes of configuration within an NGINX server setup.
Usage of this directive should be approached with careful consideration of user-agents that are likely to benefit from gzip compression versus those that would not. Misconfigurations or overly broad user-agent patterns might lead to suboptimal responses being sent to compatible clients.
Config Example
gzip on; gzip_disable "msie6"; gzip_disable "Mozilla/5.0";
Using overly broad user-agent patterns can lead to disabling Gzip for unintended clients.
Regex patterns need to be properly escaped to function as expected, otherwise they may not match correctly.