Back to DevLog

nginx proxy_cache makes post-deploy HTML checks lie for 5 minutes

1 min read

I deployed a change to the EpsteinScan homepage and immediately checked it. The old HTML was still there. Cloudflare reported cf-cache-status: DYNAMIC, which made it look like nginx was bypassing the cache. It wasn't.

nginx caches HTML itself

nginx has proxy_cache app_cache on location = / with proxy_cache_valid 200 5m. Cloudflare reporting DYNAMIC is true and irrelevant, because nginx caches the HTML itself for 5 minutes.

use_stale updating hides the refresh

The config also sets proxy_cache_use_stale ... updating and proxy_cache_lock. The first request after expiry still returns STALE while a background refresh runs. A single check can read "not deployed" a second after the cache actually updated.

read the cache file on disk

The reliable check is reading the on-disk cache file at /tmp/nginx_cache/<last1>/<last3:2>/<md5 of $scheme$host$request_uri>. Wait 5 minutes or read that file before trusting any post-deploy check.

Share this post