add_trailer
The `add_trailer` directive allows you to append custom headers to the response trailer in HTTP/2 and HTTP/3 protocols.
Description
The add_trailer directive is used to specify custom header fields that are included in the response trailer section of HTTP/2 and HTTP/3 responses. Trailers are additional HTTP headers sent after the body of a message. This may be useful for including metadata or status information that is only determined after the main payload has been sent.
This directive accepts 2 to 3 parameters: the first parameter is the name of the header to be added, and the subsequent parameters are the values to associate with that header. The values can include variables, making this directive flexible for dynamic header content. If multiple values are specified, they will be concatenated with a comma.
It's important to note that not all clients handle trailers well, so developers should ensure that their applications can manage responses that include trailer information properly. Additionally, proper care should be taken when using this directive because it can affect caching and client behavior depending on the headers added.
Config Example
server {
location /example {
add_trailer X-Custom-Trailer "Trailer Value";
}
}Not all clients support response trailers, which may limit the usability of the add_trailer directive.
Ensure correct formatting and valid header names to avoid issues with improper HTTP headers.