srcache_store_private

The `srcache_store_private` directive enables caching of private response data from subrequests in NGINX.

Syntaxsrcache_store_private on | off;
Defaultoff
Contexthttp, server, location
Argumentsflag

Description

The srcache_store_private directive is utilized in NGINX's srcache module to control the caching behavior of private responses retrieved through subrequests. When set to on, it allows private response data—those typically marked by HTTP headers, such as Cache-Control: private—to be stored in the cache, thus modifying the default behavior where these responses are usually exempt from caching and treated as uncacheable. This directive can be especially useful in scenarios where even private data might benefit from caching, provided that the caching mechanism is designed to handle such sensitivity correctly.

This directive's placement is flexible, allowing usage at three context levels: http, server, and location. By utilizing it in the right context, administrators can finely tune the caching strategy according to the application's data access patterns. It accepts a simple flag, where on enables the caching of private content and off disables this feature. Effectively, enabling this directive allows for better performance by minimizing data duplication requests to backend services, although careful consideration must be given to the privacy implications of caching such data.

Config Example

location /mydata {
    srcache_store_private on;
    srcache_store mycache;
}

Be cautious of privacy implications when caching private data as it may lead to inadvertent exposure of sensitive information if not configured correctly.

Ensure the backend service correctly operates with cached private responses to avoid inconsistencies.

← Back to all directives