fix(ui): prevent stale page keys on back navigation - #374
Merged
Conversation
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.
Summary
ui.Handler'sCache-Controlvalue withno-storebefore rendering any responseHeadHTMLor equivalent request-key metadataRationale
JaWS page HTML contains a one-use Request key. If Back navigation reconstructs a page from an HTTP-cached response, that page retries the consumed key and the WebSocket endpoint returns 404.
Reloading specifically for that 404 is not available to browser code: the WebSocket API deliberately does not expose enough opening-handshake failure information to distinguish it from other connection failures. Marking the page response
no-storeinstead prevents an HTTP cache from reusing the stale capability. The existing persisted-pageshowreload remains the separate fallback for bfcache restoration.References:
Compatibility
ui.Handlerunconditionally replaces any existingCache-Controlvalue withno-store, including when its template omitsHeadHTML. This is intentional:ui.Handleris the full-page helper and caching a response that may contain a one-use key is not safe. There is no opt-out.Custom page handlers must include the
no-storedirective themselves. Responses already cached before deployment are not repaired retroactively and may fail once until refreshed. POST history entries retain the browser's normal resubmission behavior.Verification
go generate ./...go vet ./...gofmt -l .gofumpt -l .staticcheck ./...golangci-lint rungosec ./...go build ./...JAWS_REQUIRE_NODE=1 go test -race ./...JAWS_REQUIRE_NODE=1 go test ./...The optional 386 test binaries cannot execute on this arm64 host (
exec format error); the repository'sbuild-386CI job remains the verification leg for that architecture.