Hosting · WordPress · performance · infrastructure
explainer

Nginx Cache Revalidation: How proxy_cache_revalidate and fastcgi_cache_revalidate Use Conditional Upstream Requests

Short answer

Nginx proxy_cache_revalidate and fastcgi_cache_revalidate enable revalidation of expired cache items using conditional upstream headers. Review their syntax, defaults, and context rules.

Research-based

Last verified:

Applies to: NGINX HTTP proxy and FastCGI cache modules; revalidation directives from 1.5.7+, background updates where supported from 1.11.10+

Comparison of proxy and FastCGI cache revalidation directives

Nginx provides directives to revalidate expired cache items using conditional HTTP requests. Both proxy_cache_revalidate in ngx_http_proxy_module and fastcgi_cache_revalidate in ngx_http_fastcgi_module are disabled by default. Enabling either directive instructs Nginx to verify expired items with the backend server using conditional header fields.

Directive Syntax, Defaults, and Availability

Official Nginx documentation defines identical configuration parameters, defaults, contexts, and version history for both revalidation directives:

  • proxy_cache_revalidate:
    • Syntax: proxy_cache_revalidate on | off;
    • Default: proxy_cache_revalidate off;
    • Context: http, server, location
    • Availability: Appeared in version 1.5.7.
  • fastcgi_cache_revalidate:
    • Syntax: fastcgi_cache_revalidate on | off;
    • Default: fastcgi_cache_revalidate off;
    • Context: http, server, location
    • Availability: Appeared in version 1.5.7.

Because the default is off, conditional revalidation does not run unless explicitly set to on within the relevant configuration context.

Conditional Request Headers: If-Modified-Since and If-None-Match

For both modules, setting revalidation to on enables revalidation of expired cache items using conditional requests with the If-Modified-Since and If-None-Match header fields.

Client Header Suppression Under Active Caching

In ngx_http_proxy_module, when caching is enabled, Nginx does not pass the following client request headers to the proxied server:

  • If-Modified-Since
  • If-Unmodified-Since
  • If-None-Match
  • If-Match
  • Range
  • If-Range

Background Updates and Stale Cache Rules

The documentation also defines mechanisms for updating expired items in the background while returning stale responses:

  • FastCGI module: fastcgi_cache_background_update (appeared in version 1.11.10; default off; context http, server, location) allows starting a background subrequest to update an expired cache item while returning a stale cached response to the client. The documentation specifies that it is necessary to allow the usage of a stale cached response when it is being updated, which is configured via fastcgi_cache_use_stale using the updating parameter.
  • Proxy module: The proxy module excerpt similarly documents that starting a background subrequest to update an expired cache item while returning a stale response requires allowing stale response usage when updating, configured via proxy_cache_use_stale with the updating parameter.
Comparison of revalidation and background cache updates

Text version of the diagrams

  • Proxy vs FastCGI Revalidation: Proxy cache — proxy_cache_revalidate; Shared behavior — Conditional cache checks; FastCGI cache — fastcgi_cache_revalidate
  • Revalidation vs Background Update: Revalidation — Checks expired content; Background update — Refreshes expired content; Stale response — Served while updating

Research Method and Documented Limitations

This article was prepared strictly from the supplied public documentation excerpts for ngx_http_proxy_module and ngx_http_fastcgi_module. It does not report hands-on benchmarking, lab testing, or unverified operational inferences.

Material limitations of the visible evidence include truncated module passages, the absence of upstream 304 response handling details, and the lack of variable definitions such as $upstream_cache_status. In addition, the reviewed DigitalOcean competitor page contained only generic portal text and offered no technical coverage of Nginx cache revalidation.

Related guides