gzip_no_buffer
The 'gzip_no_buffer' directive disables buffering of the gzip compression output.
Description
The gzip_no_buffer directive in NGINX is used to control output buffering for responses being gzip-compressed. When set to 'on', this directive allows NGINX to send the compressed output directly to the client without buffering the entire response in memory first. This behavior is particularly useful for larger responses or when real-time streaming of data is essential, as it reduces memory usage and potentially increases throughput by sending data to the client as it is generated. Conversely, setting this directive to 'off' (which is the default) enables buffering and allows the entire response to be held in memory before it is compressed and sent, which can be advantageous for optimizing how responses are delivered, especially when the server can benefit from data deduplication and compression efficacies.
The directive accepts a single flag argument: 'on' or 'off'. When activated, responses are sent directly without being buffered, while leaving it off will result in standard buffered behavior. It's important to note that turning off buffering may impact performance in specific scenarios, particularly when handling many simultaneous requests or large responses, as the overhead of dynamically compressing data may increase operational load.
Config Example
http {
gzip on;
gzip_no_buffer on;
}Enabling this directive can lead to increased resource usage if many clients request large files at the same time, as responses will not be buffered and could overwhelm the server's CPU and memory resources.
Make sure to test the application behavior with this directive enabled, as it may expose issues with streaming or large responses that were previously masked by buffering.