Skip to content

fix(deploy): send Cache-Control with the frontend build - #417

Merged
nourshoreibah merged 1 commit into
mainfrom
fix/frontend-cache-headers
Oct 17, 2026
Merged

nourshoreibah merged 1 commit into
mainfrom
fix/frontend-cache-headers

Conversation

@nourshoreibah

Copy link
Copy Markdown
Collaborator

Bug

After tonight's deploy (#416), opening branchaccounting.org while signed in spun forever. Typing /reports loaded fine. A hard reload did not help.

Cause

The frontend's S3 objects have no Cache-Control, so browsers cache HTML and the Next RSC payloads (*/index.txt) heuristically from Last-Modified, often for hours. The user's HAR showed:

  • the page shell and CSS came from the new build (last-modified: Oct 17 01:29)
  • /dashboard/index.txt came from disk cache, from the Oct 15 build (b: RK3Hcr…). The live build is tJ4wg3….

/ loads, then client-navigates to the landing page with router.replace, which fetches that payload with fetch(). The new runtime got an old-build payload and never rendered the page; no GET /projects/dashboard was ever sent. A direct load of /reports is a full document load, which is why that worked. Cmd+Shift+R doesn't help because the router's later fetch() still reads the HTTP cache.

The CloudFront /* invalidation only clears the edge. Browser caches are untouched.

Fix

  • Hashed _next/static/* assets: public, max-age=31536000, immutable. They're uploaded first, so new HTML never references a chunk that isn't there yet.
  • Everything else (HTML, RSC .txt, images): no-cache, so the browser revalidates on every visit and gets a cheap 304 when nothing changed.
  • The workflow file is added to the deploy's trigger paths, so merging this redeploys right away with the new headers.

After merge

Browsers already holding the old cached index.txt keep using it until it expires on its own. For anyone stuck now: DevTools → right-click reload → Empty Cache and Hard Reload, or Site settings → Delete data. Afterwards, check that curl -sI https://branchaccounting.org/dashboard/index.txt shows cache-control: no-cache.

🤖 Generated with Claude Code

S3 objects had no Cache-Control, so browsers cached HTML and the RSC
index.txt payloads heuristically from Last-Modified. After a deploy the
new JS fetched an old build's payload from disk cache on client-side
navigation (/ -> /dashboard) and the page spun forever. Hashed
_next/static assets are now immutable; everything else is no-cache.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
github-actions Bot added a commit that referenced this pull request Oct 17, 2026
@nourshoreibah nourshoreibah added the no-review The PR review bot won't run label Oct 17, 2026
github-actions Bot added a commit that referenced this pull request Oct 17, 2026
@nourshoreibah
nourshoreibah merged commit 50ecd8b into main Oct 17, 2026
18 checks passed
@nourshoreibah
nourshoreibah deleted the fix/frontend-cache-headers branch October 17, 2026 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-review The PR review bot won't run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant