proxy_buffering

The proxy_buffering directive enables or disables buffering of responses from proxied servers. — NGINX HTTP Core

proxy_buffering
httpserverlocation
Синтаксисproxy_buffering on | off;
По умолчаниюon
Контекстhttp, server, location
МодульNGINX HTTP Core
Аргументыflag

Описание

The `proxy_buffering` directive in NGINX controls whether responses from proxied servers are buffered before being sent to clients. When set to 'on', NGINX buffers the entire response from the proxied server, which can improve performance by allowing NGINX to send the response to the client in a single, optimized network operation. This can be particularly beneficial for large responses where connection overhead can significantly impact performance. Conversely, setting `proxy_buffering` to 'off' allows NGINX to transmit the response to the client as it is being received, which can be useful if you want to stream data directly or have low-latency requirements, such as in real-time applications. The directive can be applied in various contexts such as http, server, and location, giving you flexibility in what parts of your application utilize buffering based on specific performance needs. If you have multiple backends and need different buffering configurations for each, you can adjust the `proxy_buffering` setting to fit those scenarios separately. Note that when buffering is enabled, NGINX will also use the settings defined by other proxy-related directives such as `proxy_buffers` and `proxy_buffer_size` to manage how much data to buffer before sending it to the client.

Пример конфига

location /api {
    proxy_pass http://backend;
    proxy_buffering off;
}

Disabling buffering can lead to increased memory usage if responses are large and slow to send.

When proxy_buffering is turned off, clients may experience partial responses before the entire response is fully available.