Turn down widget edge stale-while-revalidate to one hour#359
Merged
Conversation
The site is low-traffic, so a day-long edge SWR window mostly means the few viewers who see a widget get served stale data while background revalidation lags, rather than meaningfully smoothing origin load. Default the edge stale-while-revalidate to one hour; the pageviews widget keeps a day since its counts barely change.
✅ Deploy Preview for giventotri canceled.
|
Its data changes rarely, so serving a stale copy while revalidating costs nothing — same rationale as the pageviews widget.
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.
What
Lowers the edge
stale-while-revalidatewindow for the live-updating widgets from 1 day to 1 hour, except the pageviews widget, which keeps 1 day.Why
The site is low-traffic, so a day-long SWR window doesn't meaningfully smooth origin load — it mostly means the handful of people who do see a widget get served stale data while Netlify revalidates the origin in the background. A one-hour window keeps the widgets reasonably fresh while still riding out a brief origin blip / cold start. Pageview counts barely change, so that widget is left at a day.
Changes
LiveWidget#cache_widgetnow takes anedge_stale_while_revalidate:param, defaulting to the newDEFAULT_EDGE_STALE_WHILE_REVALIDATE = 1.hour(was the sharedEDGE_STALE_WHILE_REVALIDATE = 1.day).stale-if-error(the error-resilience directive) is unchanged at 1 day.PlausibleController#pageviewspassesedge_stale_while_revalidate: 1.dayto opt back into the longer window.stale-while-revalidate=3600; pageviews still expects86400.api/CLAUDE.mdcaching notes.Testing
bundle exec rspecfor all affected request specs passes (52 examples, 0 failures).https://claude.ai/code/session_013dEJ89LaGXwAa6dqngRCkP
Generated by Claude Code