Skip to content

Add stale-if-error to app shell Cache-Control#4009

Merged
Celant merged 2 commits into
mainfrom
app-shell-stale-if-error
May 25, 2026
Merged

Add stale-if-error to app shell Cache-Control#4009
Celant merged 2 commits into
mainfrom
app-shell-stale-if-error

Conversation

@Celant
Copy link
Copy Markdown
Member

@Celant Celant commented May 25, 2026

Description:

Adds stale-if-error=86400 to the Cache-Control header set on the rendered app shell (/) in src/server/RenderHtml.ts. This 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 for the / route on CloudFlare in "respect origin headers" mode — it already honors s-maxage (5 min edge TTL) and stale-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:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory
  • I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced

Please put your Discord username so you can be contacted if a bug or regression is found:

jish

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>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 25, 2026

Review Change Stack

Walkthrough

The PR updates the app shell Cache-Control header to include stale-if-error=86400, allowing stale content to be served for up to 24 hours when errors occur, and updates the test expectation accordingly.

Changes

App shell cache control header update

Layer / File(s) Summary
App shell cache control header and test
src/server/RenderHtml.ts, tests/server/RenderHtml.test.ts
APP_SHELL_CACHE_CONTROL now includes stale-if-error=86400; the test expectation for setAppShellCacheHeaders was updated to match the new header value.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

When headers whisper through the net,
A little grace for outages set,
Stale but steady, twenty-four bright,
Serving pages through the night. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add stale-if-error to app shell Cache-Control' clearly and concisely summarizes the main change in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description clearly explains the change: adding stale-if-error=86400 to Cache-Control header for the app shell, its purpose for shared caches during origin errors, and how it pairs with CloudFlare configuration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2b45813 and 25ae4ae.

📒 Files selected for processing (1)
  • src/server/RenderHtml.ts

Comment thread src/server/RenderHtml.ts
@github-project-automation github-project-automation Bot moved this from Triage to Development in OpenFront Release Management May 25, 2026
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Celant Celant merged commit 2d6342c into main May 25, 2026
13 of 24 checks passed
@Celant Celant deleted the app-shell-stale-if-error branch May 25, 2026 20:13
@github-project-automation github-project-automation Bot moved this from Development to Complete in OpenFront Release Management May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

1 participant