postpone_gzipping
The 'postpone_gzipping' directive controls when NGINX applies gzip compression to responses, allowing for optimization of server resources.
Description
The 'postpone_gzipping' directive in NGINX specifies whether gzip compression of response bodies should be delayed until the response headers are sent. By default, serialization of response data into gzip format is performed immediately. However, when set to 'on', NGINX postpones the compression until after the HTTP headers have been sent, which may be beneficial in cases where the server must prioritize the timely response of headers to the client over the compression overhead. This setting can optimize resource usage and improve perceived latency especially for large responses.
The directive can be utilized in various contexts including http, server, and location blocks. When applied, it can take a single argument of 'on' or 'off'. If set to 'on', NGINX will defer the gzipping process, which allows for flexibility in handling specific types of responses or during particular phases of request handling. Conversely, setting it to 'off' or not specifying it will lead NGINX to perform gzipping immediately, applying any configured compression settings as soon as the response body is created.
Config Example
http {
gzip on;
postpone_gzipping on;
}Ensure that using 'postpone_gzipping on' does not adversely affect response time for large payloads.
Remember that this setting applies to gzip responses; make sure your configuration supports gzip compression correctly.