Add stale-if-error to app shell Cache-Control#4009
Conversation
Lets shared caches (CloudFlare, nginx proxy_cache) keep serving the last good index.html for up to 24h if origin returns a 5xx, alongside the existing stale-while-revalidate window. Pairs with enabling HTML caching on CloudFlare for the / route. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
WalkthroughThe PR updates the app shell ChangesApp shell cache control header update
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/server/RenderHtml.ts`:
- Line 10: The test expectation in tests/server/RenderHtml.test.ts must be
updated to match the new Cache-Control header emitted by RenderHtml (the string
in RenderHtml.ts was changed to "public, max-age=0, s-maxage=300,
stale-while-revalidate=86400, stale-if-error=86400"); open
tests/server/RenderHtml.test.ts and replace the old expected Cache-Control value
with the new full string so the assertion for the Cache-Control header (around
the assertion block at lines ~52-66) matches the value produced by
RenderHtml.renderHtml / the Cache-Control constant.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ace019fd-798f-441d-90e5-135e9f904005
📒 Files selected for processing (1)
src/server/RenderHtml.ts
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Description:
Adds
stale-if-error=86400to theCache-Controlheader set on the rendered app shell (/) in src/server/RenderHtml.ts. This lets shared caches (CloudFlare, nginxproxy_cache) keep serving the last goodindex.htmlfor up to 24h if origin returns a 5xx, alongside the existingstale-while-revalidatewindow.Pairs with enabling HTML caching for the
/route on CloudFlare in "respect origin headers" mode — it already honorss-maxage(5 min edge TTL) andstale-while-revalidate; this just extends the same safety net to origin-error cases.No behavior change for successful responses; browsers still revalidate every load via
max-age=0.Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
jish