I have ran into an issue where using
fastcgi_cache_use_stale
withfastcgi_cache_background_update
can cause issues with 404 pages. If you ever delete a page that has been cached, nginx will keep serving the cached page even if your origin server responds with 404.It’s because WordPress adds
Cache-Control: no-cache, must-revalidate, max-age=0
andexpires: Wed, 11 Jan 1984 05:00:00 GMT
to 404 pages which nginx will refuse to cache.That’s why you should use
any
value infastcgi_cache_valid
and always usefastcgi_ignore_headers Cache-Control Expires
. This way your deleted pages will properly return 404 error code. I have updated the code samples to reflect this.
What is your fastcgi_cache_valid
?
My guess is:
Nginx refuses to update the cache because private pages have Cache-Control: no-cache
header. Thus, the old caches (the published version) are used.