Response caching for proxied content is enabled in the http, server, or location context. proxy_cache_path, valid in http, sets the on-disk cache path and parameters: cached data is stored in files whose names are the result of applying the MD5 function to the cache key, the levels parameter defines a hierarchy of one to three levels where each level accepts the values 1 or 2, and keys_zone allocates a shared memory zone that can be used in several places, as in proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=one:10m. A cached response is first written to a temporary file and then renamed; if temporary files and the cache sit on different file systems, the file is copied across them instead of the cheap renaming operation. proxy_cache zone activates caching and the off parameter disables caching inherited from the previous configuration level. proxy_cache_bypass defines conditions under which the response is not taken from the cache when any parameter value is non-empty and not 0. Since 1.11.10, proxy_cache_background_update refreshes an expired item in a background subrequest while the stale response is returned to the client, which requires stale usage to be allowed explicitly. Scope: nginx. Reviewed October 4, 2026.
Response caching with proxy_cache
Document v1 · published by Koskamo editorial · updated 2026-10-04
Source and provenance
- Original source
- nginx.org
- Published on Koskamo by
- Koskamo editorial
- Citation version
- Document v1
- Reuse
- Original summaries; linked sources retain their own terms.