srcache_store_no_store
The `srcache_store_no_store` directive controls whether responses should be stored in the transparent subrequest cache based on the 'no-store' directive in `Cache-Control` headers.
Description
The srcache_store_no_store directive is used within the context of HTTP, server, and location blocks in NGINX, specifically with the transparent subrequest-based caching mechanism facilitated by the ngx_srcache module. When this directive is set to 'on', it instructs NGINX to respect the 'no-store' cache control directive in HTTP responses. This means that if a response contains a 'Cache-Control: no-store' header, NGINX will not store the response in the cache, even if other configurations might allow it. Conversely, if set to 'off', NGINX will ignore the 'no-store' directive, allowing these responses to be cached, potentially leading to caching of sensitive or dynamic content that was intended for non-storage.
This directive thus serves as a crucial mechanism for ensuring that certain data, deemed sensitive or often changing, is not cached inadvertently, thus adhering to the HTTP caching specifications regarding what content should be cached. It plays a key role in maintaining the integrity and privacy of cached data by ensuring compliance with the source server's cache directives. Proper utilization of this directive can help avoid caching issues in environments where data privacy or the accuracy of frequently changing responses is critical.
Config Example
location /api {
srcache_store_no_store on;
srcache_fetch my_cache;
}
location /public {
srcache_store_no_store off;
srcache_fetch my_cache;
}Ensure that this directive is only set in the intended contexts; misplacement may lead to unexpected caching behavior.
Setting srcache_store_no_store on in a high-traffic location can lead to significant bypassing of cache efficiency if many responses include 'Cache-Control: no-store'.
Be aware of upstream server caching directives that may conflict with this setting, leading to challenges in expected behavior.