Repository navigation
infra(cloudfront): content-hashed assets immutable for a year, loader JSON no longer edge-cached for a day - #809
Merged
Merged
Conversation
…d loader JSON is no longer edge-cached for a day (#788) EAS Hosting hard-codes a one-hour browser cache on every static asset and offers no override, so a visitor who returns after an hour re-downloaded the whole bundle for a URL that cannot change. CloudFront is the only place to fix that: a `/_expo/static/*` behaviour now carries the `scaffald-immutable-assets` response headers policy (`public, max-age=31536000, immutable`), on the prod, dev and preview distributions. The HTML's caching is untouched. Found while placing that behaviour: `/_expo/loaders/*` — the JSON that client-side navigation fetches for route loaders — fell under `/_expo/*` and its CachingOptimized policy, and because the origin sends no Cache-Control on loader responses, the edge kept them for the policy's 24 h default. A client-side jump to /jobs could show a day-old listing beside a server render that was 60 s old (`x-cache: Hit`, growing `age`). Loaders now use the same `scaffald-ssr-html` policy as the pages they belong to, query strings in the key. The live distribution config replaces the S3-era file that described a pipeline deleted in August; the deploy script asserts the two headers after every deploy so a console edit cannot silently undo this. Co-Authored-By: Claude Fable 5.1 <[email protected]>
18 of 23 tasks
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.
Closes #788. Part of #802.
The AWS change is already applied and verified (it lives in the account, not the repo); this PR records it, replaces the stale S3-era CloudFront config with the live one, and makes the deploy script assert the headers so a console edit cannot silently undo them.
What changed on CloudFront
EAS Hosting hard-codes
max-age=3600on every static asset with no override (its caching reference: "a default cache time of 3600 seconds will be applied for browser caches";Cache-Controlis honoured for API routes only). So this is a CloudFront response headers policy, on all three distributions:/_expo/static/*Managed-CachingOptimizedscaffald-immutable-assets260ff2ed-5e41-4d44-b320-fd767d111371→public, max-age=31536000, immutable/_expo/loaders/*scaffald-ssr-html(0 / 60 s / 3600, query strings in the key) +AllViewerExceptHostHeaderProduction, verified after
Deployed:The second finding, fixed in the same edit
/_expo/loaders/*— the JSON that client-side navigation fetches for route loaders — fell under the existing/_expo/*behaviour and itsCachingOptimizedpolicy. The origin sends noCache-Controlon loader responses, so the edge kept them for that policy's 24-hour default: three consecutive fetches of/_expo/loaders/jobsreturnedx-cache: Hitwithage32 → 34 → 36. A client-side jump to/jobscould show a day-old listing next to a server-rendered page that was 60 s old. Loaders now use the samescaffald-ssr-htmlpolicy as the pages they belong to. This was outside #788's text; flagging it here rather than leaving it.Dev and preview
dev.scaffald.comandpreview.scaffald.comare behind their own distributions (E3J4DOM99FE5N,E1YYVZYC1XER5O) with only a default behaviour, so they got the same two behaviours in front of it — every custom domain now answers the same way, and the deploy script's assertion holds for all three targets. Only the raw*.expo.appURLs keep EAS's hour.In the repo
infra/aws/cloudfront/apex-distribution-config.json— the liveE1JU35IZ18YNELconfig (get-distribution-config,CallerReferencestripped), replacingdistribution-config.json, which described the S3 + OAC pipeline deleted 2026-08-03.infra/aws/cloudfront/response-headers-immutable-assets.json— the policy as created.scripts/deploy-web-eas.sh— after the reachability smoke, fetches the entry bundle and the HTML and fails if the bundle is notimmutableor the HTML is.docs/agents/SSR-DEPLOY.md,infra/aws/README.md— behaviours, policy id, the loader finding, expected headers.Not comparable to Lighthouse: cold-load numbers do not see repeat-visit caching, which is why this was a separate issue.
🤖 Generated with Claude Code