srcache_header_buffer_size

The `srcache_header_buffer_size` directive specifies the size of the buffer used for caching HTTP headers in subrequests.

Syntaxsrcache_header_buffer_size size;
Defaultnone
Contexthttp, server, location, if in location
Arguments1

Description

The srcache_header_buffer_size directive is part of the transparent subrequest-based caching module for NGINX, which allows caching of responses for arbitrary locations. This directive directly affects the size of the buffer allocated for storing HTTP headers when a subrequest is issued. In scenarios where headers are large, setting an appropriate buffer size can help prevent truncation or memory issues. The parameter takes a single argument that defines the size in bytes, which can also be expressed in kilobytes (K) or megabytes (M).

The directive can be used in multiple contexts such as http, server, location, and within an if block inside a location. This flexibility allows for granular control over caching behavior in different parts of the NGINX configuration. It’s important to note that if the size defined is too small for the headers being processed, it may lead to unexpected results, such as incomplete or corrupted headers in the cache. Therefore, users should be cautious and test various sizes according to the specific needs of their application.

Config Example

server {
    location /api {
        srcache_header_buffer_size 16k;
    }
}

Setting the buffer size too small might lead to header truncation errors.

Changes to this directive might not be immediately observable unless the cache is cleared or revalidated.

← Back to all directives