subs_line_buffer_size

The `subs_line_buffer_size` directive defines the size of the internal buffer used for line-based string substitutions in response bodies.

Syntaxsubs_line_buffer_size size;
Defaultnone
Contexthttp, server, location
Arguments2

Description

The subs_line_buffer_size directive is part of the NGINX String Substitutions Module, providing control over the internal buffer size utilized when processing string replacements in the response body. This buffer plays a crucial role in ensuring that the module can efficiently handle larger lines of text during substitution operations. By default, the module may not allocate any extra space beyond its necessary requirements, which could lead to performance limitations when working with lengthy response bodies or numerous substitution rules.

When configured, the value set for subs_line_buffer_size directly influences how much memory is reserved for processing lines during the substitution phase. Allocating more buffer size can enhance performance by reducing the frequency of memory reallocations and the overhead associated with handling multiple smaller buffers. However, excessive buffer sizing may lead to inefficient memory usage, especially if the application generally handles short lines or operates under peak loads.

This directive can be defined in the http, server, or location contexts, making it flexible for various configuration scopes. The syntax for defining the directive includes specifying the desired buffer size (e.g., in bytes or using suffixes like k for kilobytes, m for megabytes). This allows for tailored configurations accommodating specific response processing needs depending on the expected content volume and complexity of the substitution patterns in use.

Config Example

http {
    subs_line_buffer_size 32k;
}

Setting the buffer size too low can lead to substitution failures on larger response bodies.

Excessive buffer sizes can waste memory, especially in environments with many short lines.

← Back to all directives