Skip to content

Let Back restore a locally served page from the page cache - #3450

Merged
max-sixty merged 1 commit into
mainfrom
back-restores-local-pages
Oct 21, 2026
Merged

max-sixty merged 1 commit into
mainfrom
back-restores-local-pages

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

The local page server now answers documents and API requests with Cache-Control: no-cache instead of no-store, so Chrome and Firefox keep a Leaf page in their back/forward cache. Pressing Back after following a link, such as a PR link on a page, now shows the page at once instead of loading it from scratch. leaf.page keeps no-store, including on its container's Python answers. This implements Max's decision #6 on the overnight report.

no-cache lets the browser store an answer but has it check with the server before each reuse. The server sends no validator, so each reuse is a full fetch, and every load shows the page as it is now. The stored copy holds what the page directory already keeps in plain files under the same user's state home.

leaf.page keeps no-store because there the stored copy is new: a visitor's private comments and replies would stay in the browser's disk cache after their session ends, readable by anyone who later uses that browser profile. WebsitePageEndpoint overrides the class attribute, and a live sample's child page uses its parent's setting.

Evidence

I served release-notes (no samples) and corpus (samples) from the merge base and from this branch, followed a link off the page, opened a thread from the CLI while the page was away, pressed Back, and waited until the page had applied a /api/state answer taken after that thread. Then I left again, opened another thread and loaded the URL afresh. Chromium is Playwright's full Chromium 153 with Playwright's --disable-back-forward-cache removed. Firefox is the installed Firefox 158.0.1 driven through geckodriver, because Playwright's Firefox disables its page cache in the docshell.

Base (no-store) This branch (no-cache)
Chromium, release-notes, Back reloaded (MainResourceHasCacheControlNoStore, JsNetworkRequestReceivedCacheControlNoStoreResource), current after 243 ms restored (pageshow.persisted), fetched /api/state 4 ms after pageshow, current 43 ms after Back
Firefox, release-notes, Back reloaded, current after 336 ms restored, current 31 ms after Back
Firefox, corpus (samples), Back not run not restored, as expected for a page holding a sample; the document was fetched again (767,652 bytes) and the page showed the current state
Chromium, corpus, Back not run restored, current 278 ms after Back
Chromium, release-notes, Back with an unload handler (no page cache) not run document fetched again (183,869 bytes), current
Fresh load after a change, every case full fetch, current full fetch, current

Safari wasn't tried. The run is recorded in notes/browser-support.md, "Page cache", and the open leaf.page half of the question stays in TODO.md.

This was written by Claude Code on behalf of max-sixty

The local page server answers with `Cache-Control: no-cache` instead of
`no-store`, so Chrome and Firefox keep a Leaf page in their back/forward
cache and Back shows it at once. With no validator sent, every reuse is
still a full fetch. leaf.page keeps `no-store`: there a visitor's private
comments would otherwise stay in the browser's disk cache after their
session ends. Max's decision #6 on the overnight report.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 06c3a55 into main Oct 21, 2026
3 checks passed
@max-sixty
max-sixty deleted the back-restores-local-pages branch October 21, 2026 07:18
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