Skip to content

Turn down widget edge stale-while-revalidate to one hour#359

Merged
gesteves merged 2 commits into
mainfrom
claude/swr-cache-tuning-s2u0a0
Jun 9, 2026
Merged

Turn down widget edge stale-while-revalidate to one hour#359
gesteves merged 2 commits into
mainfrom
claude/swr-cache-tuning-s2u0a0

Conversation

@gesteves

@gesteves gesteves commented Jun 9, 2026

Copy link
Copy Markdown
Owner

What

Lowers the edge stale-while-revalidate window 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_widget now takes an edge_stale_while_revalidate: param, defaulting to the new DEFAULT_EDGE_STALE_WHILE_REVALIDATE = 1.hour (was the shared EDGE_STALE_WHILE_REVALIDATE = 1.day). stale-if-error (the error-resilience directive) is unchanged at 1 day.
  • PlausibleController#pageviews passes edge_stale_while_revalidate: 1.day to opt back into the longer window.
  • Updated request specs (activity-stats, whoop, weather, trending, events) to expect stale-while-revalidate=3600; pageviews still expects 86400.
  • Updated api/CLAUDE.md caching notes.

Testing

bundle exec rspec for all affected request specs passes (52 examples, 0 failures).

https://claude.ai/code/session_013dEJ89LaGXwAa6dqngRCkP


Generated by Claude Code

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.
@netlify

netlify Bot commented Jun 9, 2026

Copy link
Copy Markdown

Deploy Preview for giventotri canceled.

Name Link
🔨 Latest commit e18bfcb
🔍 Latest deploy log https://app.netlify.com/projects/giventotri/deploys/6a27f2f693cd0a00080ebe04

Its data changes rarely, so serving a stale copy while revalidating costs
nothing — same rationale as the pageviews widget.
@gesteves gesteves merged commit 9a564d0 into main Jun 9, 2026
8 checks passed
@gesteves gesteves deleted the claude/swr-cache-tuning-s2u0a0 branch June 9, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants