Initial impact: a green deploy and an old site
- The build itself, which may have restored stale output from its build cache.
- The deployment, which may have gone to a branch that is not production.
- The Cloudflare edge for your custom domain, if zone-level cache rules apply.
- The browser cache.
- A service worker registered by the site.
Investigation: ruling out layers one at a time
<hash>.<project>.pages.dev. That URL points at exactly one build artifact, so it is the ground truth for what that build produced.
Compare the response headers from both:
BASH
# Production domain
curl -sI 'https://www.example.com/' | grep -iE 'cf-cache-status|age|etag|cache-control'
# Unique deployment URL copied from the Pages deployments list
curl -sI 'https://abc123.my-project.pages.dev/' | grep -iE 'cf-cache-status|age|etag|cache-control'cf-cache-statustells you whether Cloudflare served the response from its cache.HITmeans it came from cache.MISSorDYNAMICmeans it was fetched fresh.ageis how many seconds the cached copy has been sitting at the edge.etagis a fingerprint of the content.
etag values differ and production shows HIT with a large age, the production domain is serving a cached copy from before the deploy. The earlier article on reading cf-ray and cf-cache-status headers covers these headers in more depth.
If the unique deployment URL itself shows the old content, the edge cache is not the problem. The build produced old files, and the cause is earlier in the pipeline.
The discovery: which artifact is actually served
master to main, or that merged into a staging branch, often hit this. Check which branch the successful deployment was built from and compare it with the production branch set in the project's build settings.
The build cache restored stale output. Pages can keep a build cache between builds so that dependency installs and framework caches don't start from zero each time. That speeds up builds, but if a framework writes generated pages into a cached directory and its own invalidation misses a change, the build can finish quickly and successfully with old output. A hint that this is happening: the build log is suspiciously fast, or it reports that pages were restored from cache. The fix is to clear the build cache in the project settings and retry the deployment.
The output directory is wrong. This produces the blank page or 404 variant rather than stale content. In the Cloudflare community threads about deployments that show success but return an empty response or 404, the recurring explanation is that the build command ran fine but Cloudflare could not find any HTML in the configured output directory. A framework that writes to dist while the project expects build will fail this way. Direct Upload has a related trap: uploading a zip or folder that wraps the site in an extra parent directory, so index.html is not at the root.
When support engineers handle this ticket, comparing the unique deployment URL with production is usually the first thing they check, because it splits the problem in half with one request.
Temporary mitigation: purge, clear, and redeploy
BASH
# Purge specific URLs. Token needs the Zone > Cache Purge permission.
curl -s -X POST "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/purge_cache" \
-H "Authorization: Bearer $CF_API_TOKEN" \
-H 'Content-Type: application/json' \
--data '{"files":["https://www.example.com/","https://www.example.com/index.html"]}'Architectural fix: make the served version observable
BASH
# Build command in Pages settings (adjust 'dist' to your output directory)
npm run build && echo "$CF_PAGES_COMMIT_SHA" > dist/version.txt
# After deploy, compare against the commit you expect
curl -s 'https://www.example.com/version.txt'- Give HTML short or no-cache
Cache-Controlheaders. Let only content-hashed assets, such asapp.3f9c2a.js, be cached for a long time. Pages supports a_headersfile for setting this per path. - Avoid broad "Cache Everything" rules on a Pages hostname unless you also purge on every deploy. Pages manages caching for its own deployments, and a zone rule on top adds a layer it doesn't control.
- Write down which branch is production and which output directory the framework uses, so a framework upgrade or branch rename doesn't silently change either.
