Repository navigation
Serve a stale static shell while CloudFront refetches it - #12491
Merged
Merged
Conversation
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
Contributor
Code Coverage Report: Only Changed Files listed
Minimum allowed coverage is |
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.
index.htmlin 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 oni.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_REVALIDATEchanges the window, and0leaves 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_ttlraised 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.htmlfor 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