Repository navigation
fix(http): serve the edited page when a prerendered route is revalidated - #275
Merged
Merged
Conversation
A TransferState edit override had no effect on a prerendered page the browser already had: the reload sent If-None-Match, Angular's engine answered 304 from the prerendered file's ETag, and there was no HTML to edit. When an edit did go through, the response kept the unedited file's ETag, so after the override was removed the browser revalidated its edited copy with a 304 and kept showing the edit. While a state edit matches, the conditional request headers are now dropped, and an edited response drops its ETag and Last-Modified.
🚀 Deploying Preview to Cloudflare 🚀Preview Deployments by commit
|
Contributor
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.
What and why
The docs say a TransferState edit override "applies from the next full page load". That wasn't true for prerendered routes:
If-None-Matchwith the ETag it already has.@angular/ssrserves prerendered pages with anETagand answers304when it matches, so the middleware has no HTML to edit. The page comes back unedited, and no failure is recorded because a 304 has no body to check.ETag. After the override is turned off, a normal reload revalidates the edited copy, gets a 304, and the browser keeps showing edited state that no override explains.The fix only applies when a state-edit override matches the request:
if-none-matchandif-modified-sinceare removed from the request, so the engine renders a full 200 that can be edited.etagandlast-modifiedare removed from the response.Requests that match no override are unchanged.
How it was verified
New test in
ssr-overrides.test.tsthat copies Angular's prerender behavior: the engine sends a 304 whenif-none-matchmatches its ETag. Onmainthe reload gets304(expected 304 to be 200). With the fix it gets the edited 200 with no ETag. All package tests pass.pnpm commit:check(commit messages follow the guidelines)pnpm format:checkpnpm typecheck(includes thengctemplate checks)pnpm test:devtools(all passing)pnpm skills:check(when.claude/changed): not changedno-docs)pnpm extension:buildandextension/uicommitted (whenapp/changed): not changedSummary by CodeRabbit