gzip_proxied
The `gzip_proxied` directive controls gzip compression for proxied requests based on specified conditions.
Description
The gzip_proxied directive in NGINX is used to configure gzip compression for responses coming from proxied servers. By setting this directive, you can specify which requests should have their responses compressed based on conditions like the HTTP status code or the presence of specific headers in the request. The directive takes arguments such as off, expired, no-cache, no-store, private, no_last_modified, and undispositioned, among others. These arguments allow fine control over when to apply gzip compression, thus optimizing bandwidth and improving client load times based on the characteristics of the response and the request.
When enabled, the directive helps enhance the performance of web applications, especially in scenarios where response sizes are large. The conditional behavior means that you can avoid compressing responses for certain status codes (like 4xx or 5xx) or for requests that would not benefit from compression. Enabling compression can significantly reduce the amount of data transmitted over the network, therefore improving the user experience, especially for clients with slower connections. However, it is essential to configure it correctly to avoid compressing unnecessary or already-compressed content.
Config Example
http {
gzip on;
gzip_proxied expired no-cache no-store private;
}Ensure that gzip is enabled globally or at the server level for this directive to take effect.
Avoid using gzip with already-compressed files or responses as it can lead to increased overhead and unnecessary processing.
Misconfiguring the conditions may lead to some responses not being compressed when they might benefit from it.