eval_buffer_size

The eval_buffer_size directive sets the maximum buffer size for capturing response bodies in NGINX's eval module, allowing control over data storage during proxying or memcached responses.

Syntaxeval_buffer_size size;
Default4k
Contexthttp, server, location
Arguments1

Description

The eval_buffer_size directive configures the maximum size of the buffer utilized by the NGINX eval module to capture the response bodies from subrequests made within the server's configuration. When this directive is applied, it limits the size of the buffered data, ensuring that responses larger than the specified limit are truncated. This can help manage memory usage effectively when dealing with potentially large responses, as the data is typically stored in memory.

This directive is particularly useful in contexts where responses are fetched from backend services or caches and stored in variables for further processing or condition checking. By defining an appropriate buffer size, administrators can optimize performance while preventing excessive memory consumption. The directive can be specified in the http, server, or location contexts, which allows for flexibility in configuration based on needs. The default behavior, if this directive is not set, is to use a default buffer size of 4k.

Care should be taken to choose a buffer size that accommodates expected response sizes without leading to unnecessary memory usage, and responses exceeding the limit will not be fully captured, potentially leading to data loss during evaluations and checks using captured variable values.

Config Example

location = /example {
    eval_buffer_size 2k;
    eval $response {
        proxy_pass http://backend;
    }
    # Further processing can occur here using the $response variable.
}

Setting the buffer size too low can lead to truncated responses, resulting in loss of important data if the captured response exceeds this size.

Changes to eval_buffer_size may require a reload of the NGINX server to take effect, depending on the context where it is used.

← Back to all directives