Repository navigation
fix(deploy): send Cache-Control with the frontend build - #417
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
After tonight's deploy (#416), opening
branchaccounting.orgwhile signed in spun forever. Typing/reportsloaded 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 fromLast-Modified, often for hours. The user's HAR showed:last-modified: Oct 17 01:29)/dashboard/index.txtcame from disk cache, from the Oct 15 build (b: RK3Hcr…). The live build istJ4wg3…./loads, then client-navigates to the landing page withrouter.replace, which fetches that payload withfetch(). The new runtime got an old-build payload and never rendered the page; noGET /projects/dashboardwas ever sent. A direct load of/reportsis a full document load, which is why that worked. Cmd+Shift+R doesn't help because the router's laterfetch()still reads the HTTP cache.The CloudFront
/*invalidation only clears the edge. Browser caches are untouched.Fix
_next/static/*assets:public, max-age=31536000, immutable. They're uploaded first, so new HTML never references a chunk that isn't there yet..txt, images):no-cache, so the browser revalidates on every visit and gets a cheap 304 when nothing changed.After merge
Browsers already holding the old cached
index.txtkeep 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 thatcurl -sI https://branchaccounting.org/dashboard/index.txtshowscache-control: no-cache.🤖 Generated with Claude Code