srcache_store_hide_header

The srcache_store_hide_header directive specifies headers to be omitted when caching a response.

Syntaxsrcache_store_hide_header header;
Defaultnone
Contexthttp, server, location
Arguments1

Description

The srcache_store_hide_header directive in NGINX's srcache module controls which HTTP response headers are removed from the cached entries. When storing responses, some headers may not be relevant or necessary, and including them could lead to issues, such as cache pollution or unwanted client behaviors. By specifying the headers to hide using this directive, administrators can ensure that only the essential information is cached, improving the cache's effectiveness and reliability.

This directive can be applied in the http, server, and location contexts, providing flexible placement depending on the caching strategy employed. The argument takes a header name to specify which header to exclude from the cached response. Multiple invocations of the directive can be used to hide multiple headers. For example, common headers like "Set-Cookie" or "Cache-Control" can be hidden to prevent clients from receiving unwanted session or cache-related data during response retrieval from the cache.

The syntax of the directive allows the specification of one or more headers to be hidden, thus enabling optimized cache behavior for various applications. Proper configuration of this directive is crucial for maintaining efficient and lean caching of responses without unnecessary information that could impact the performance or functionality of cached content.

Config Example

location /example {
    srcache_store;
    srcache_store_hide_header "Set-Cookie";
    srcache_store_hide_header "Cache-Control";
}

Ensure that headers specified do not contain information necessary for the application's functionality, as this may lead to issues with client-side processing.

Using this directive incorrectly may result in missed caching opportunities if important headers are not checked appropriately.

← Back to all directives