Where nginx stores disk cache
proxy_cache_path defines a filesystem tree of hashed keys under a keys_zone shared memory index. Purging means either selective key eviction (via a purge module or vendor patch), rotating the zone path during maintenance, or deleting files while workers are quiesced—blind rm -rf on a live zone can corrupt entries workers still reference.
Operational patterns
| Approach | How | Tradeoff |
|---|---|---|
| Purge API | ngx_cache_purge or vendor equivalent | Must secure internal purge endpoint |
| Rotate path | Point proxy_cache_path to new directory, reload | Disk spike until old tree deleted |
| Full delete | Stop traffic or worker, remove tree, reload | Simplest blast radius |
Stampede mitigation
After purge, origins see a burst of misses—tune proxy_cache_use_stale, proxy_cache_lock, and upstream keepalive pools. Prefer versioned asset URLs so deploys rarely need mass purge.
FastCGI cache
fastcgi_cache uses parallel concepts; purge tooling must target the correct zone. Do not assume proxy_cache helpers apply without checking config.
Related: nginx reverse proxy, nginx performance tuning, Clear Cloudflare cache, Common nginx errors.