scgi_cache_purge

The `scgi_cache_purge` directive allows for the removal of cached content from the SCGI cache based on the specified cache key.

Syntaxscgi_cache_purge zone_name key;
Defaultnone
Contexthttp, server, location
Arguments1+

Description

The scgi_cache_purge directive is part of the NGINX Cache Purge module, which enables the purging of cached content from SCGI caches. This directive can be configured in the http, server, or location contexts and requires one or more arguments that specify the cache zone and cache key for purging. The primary use of this directive is to maintain cache hygiene by removing stale or outdated entries, ensuring that users receive up-to-date content.

When using scgi_cache_purge, users can specify the method through which the caching system is interacted with, and can do so conditionally based on the IP address of the client making the purge request. For instance, administrators can set the directive to allow purges only from certain IP addresses or networks, enhancing security by preventing unauthorized purging of cache. The directive integrates with the broader caching mechanism in NGINX, ensuring that when a purge request is received, the content associated with the specified key is effectively invalidated and removed from the cache.

The directive also supports responding with different content types (HTML, JSON, XML, or plain text) after a purge operation is completed, helping integrate it seamlessly into API workflows or web applications that might require confirmation of the operation performed.

Config Example

location /purge {
    scgi_cache_purge my_cache_zone $uri;
    allow 192.168.1.0/24;  # Allow purging from this IP range.
    deny all;  # Deny all other requests.
}

Ensure proper IP address filtering to avoid unauthorized purges.

Remember that the key must match the cache key used when storing content; otherwise, the purge will have no effect.

The scgi_cache_purge directive requires proper configuration to function correctly; misconfiguration can lead to cache not being purged as expected.

← Back to all directives