Skip to content

Serve a stale static shell while CloudFront refetches it - #12491

Merged
nbudin merged 1 commit into
mainfrom
shell-stale-while-revalidate
Nov 25, 2026
Merged

nbudin merged 1 commit into
mainfrom
shell-stale-while-revalidate

Conversation

@nbudin

@nbudin nbudin commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

index.html in the static shell bucket is fresh for 60 seconds. On a quiet site most visits find an expired copy at the CloudFront edge and wait for it to be revalidated: about 280 ms to first byte on i.interconlarp.org, against about 30 ms for a cache hit.

The release upload now adds stale-while-revalidate=300, so an expired copy is served at once and refetched in the background. INDEX_STALE_WHILE_REVALIDATE changes the window, and 0 leaves it out.

Infrastructure: CloudFront cuts the window off at the cache policy's maximum TTL, which is currently 60 seconds. The full 300 needs static_shell_max_ttl raised on the shared policies in neil-terraform, after neinteractiveliterature/neil-terraform#60 is applied. Until then the window is at most 60 seconds.

Trade-off: after a release, a visitor can get the previous index.html for up to about six minutes (60 fresh plus 300 stale), from the edge or from their own browser cache. The hashed files it names stay in the bucket, but that old frontend will be talking to the new backend.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UKBUsvfbUjKBu9d6FJoEuJ

index.html is fresh for 60 seconds, so on a quiet site most visits found
an expired copy at the edge and waited about 250 ms for it to be
revalidated. Give it stale-while-revalidate=300.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UKBUsvfbUjKBu9d6FJoEuJ
@nbudin nbudin added performance patch Bumps the patch version number on release labels Nov 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage Report: Only Changed Files listed

Package Base Coverage New Coverage Difference
app/graphql/concerns/cms_parent_implementation.rb 🔴 45.95% 🔴 43.24% 🔴 -2.71%
Overall Coverage 🟢 69.91% 🟢 69.9% 🔴 -0.01%

Minimum allowed coverage is 0%, this run produced 69.9%

@nbudin
nbudin merged commit daf7437 into main Nov 25, 2026
27 checks passed
@nbudin
nbudin deleted the shell-stale-while-revalidate branch November 25, 2026 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Bumps the patch version number on release performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant