scgi_cache_revalidate
The `scgi_cache_revalidate` directive controls whether NGINX revalidates cached SCGI responses before serving them to clients.
Description
The scgi_cache_revalidate directive in NGINX is used within the context of http, server, or location blocks. It acts as a flag that specifies whether the cached responses should be revalidated with the SCGI server before being served to the client. When this directive is set to on, NGINX will check the validity of the cached response against the backend SCGI server whenever a request for that resource is made, ensuring that clients receive the most current data. If set to off, NGINX will serve the cached content without checking its validity, potentially returning stale data if the content has changed on the server.
This directive works hand-in-hand with other caching directives such as scgi_cache, where scgi_cache defines the caching zone and scgi_cache_use_stale can be used to serve stale content when necessary. The main purpose of scgi_cache_revalidate is to ensure that data freshness is prioritized in scenarios where the backend may have updated content that should be reflected to the end user. Failing to set this flag correctly might lead to serving outdated content if the caching is implemented but revalidation is not prioritized.
Config Example
scgi_cache_path /tmp/scgi_cache levels=1:2 keys_zone=my_cache:10m;
location /example {
scgi_pass backend;
scgi_cache my_cache;
scgi_cache_revalidate on;
}Setting scgi_cache_revalidate to off may lead to serving stale content without checks.
Ensure scgi_cache is configured properly, otherwise this directive will not have any effect.