fastcgi_request_buffering

The `fastcgi_request_buffering` directive controls whether request body buffering is enabled for FastCGI requests.

Syntaxfastcgi_request_buffering on | off;
Defaulton
Contexthttp, server, location
Argumentsflag

Description

In NGINX, the fastcgi_request_buffering directive allows the administrator to enable or disable buffering of the request body when the FastCGI module handles requests. By default, when this directive is set to 'on', NGINX buffers the entire request body before passing it to the FastCGI process. This can enhance performance, especially in scenarios where the application requires the whole request data before processing.

However, setting fastcgi_request_buffering to 'off' allows requests to be streamed directly to the FastCGI application without intermediate buffering in NGINX. This is particularly useful for handling large uploads or when the application processes data in real-time. With this setting, the data can begin to be processed as it is received, potentially lowering memory consumption and improving responsiveness for large payloads or long-running requests.

The directive can be specified at the http, server, or location context levels, allowing fine-grained control over request processing behavior based on specific locations or server blocks, depending on the needs of the application it serves.

Config Example

location /upload {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_request_buffering off;
}

Disabling request buffering may lead to decreased performance for small requests due to the overhead of streaming.

Some applications may expect a fully buffered request body, which could lead to unexpected behavior when this directive is set to off.

← Back to all directives