Skip to content

fix(health-freshness): Cloudflare browser-TTL rewrite (max-age=1800) makes synthesized-OK sources oscillate to stale — client must fetch with cache:'no-cache' #4910

Description

@koala73

Post-deploy probe of #4907 / PR #4908 found the Cloudflare zone's Browser Cache TTL override rewrites the origin's Cache-Control: public, max-age=0, must-revalidate on /api/health?compact=1 to public, max-age=1800, must-revalidate (observed live; it also rewrites the gated 401's private, no-store, max-age=0 to private, max-age=1800). CDN-Cache-Control: public, s-maxage=60 is respected — cf-cache-status: HIT + x-vercel-cache: HIT confirm the origin collapse works.

But a 30-min BROWSER cache breaks the freshness display: since PR #4905, healthy checks are synthesized as OK-as-of-checkedAt and FRESH_THRESHOLD is 15 min. A tab whose browser cache serves a 15-30-min-old body computes age > threshold and flips ALL healthy sources to stale, then back to fresh when the cache window rolls — oscillating in ~30-min waves.

Fix: cache: 'no-cache' on the client health fetch — the browser revalidates every poll, Cloudflare answers from its 60s edge cache, origin stays collapsed, checkedAt stays ≤ ~60s + poll interval old (well under threshold). This is the correct client declaration for a freshness poller and is robust against future CF browser-TTL config drift. (Zone-level "respect existing headers" would also help but is CF-dashboard config outside the repo.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions