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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use sourceDocument if set for prefetch lookup #267
base: main
Are you sure you want to change the base?
Use sourceDocument if set for prefetch lookup #267
Changes from 2 commits
2d97b00
d3d7be8
c7658e8
dc87b98
4474dc5
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a WPT already for reload (#212 (comment)), but maybe just to check the Chromium behavior?
https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/web_tests/external/wpt/speculation-rules/prefetch/prefetch-traverse-reload.sub.html
Do you have examples/test cases where prefetched results would be used in this code path? (I'm not familiar with how "finalize a cross-document navigation" works)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah OK, I am happy to keep it then.
This is the most basic code path. E.g. this is the code path which clicking a link or doing
location.href
goes through.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://html.spec.whatwg.org/multipage/browsing-the-web.html#reload says:
So probably we shouldn't pass
sourceDocumentForPrefetches
as well?Also, how about passing
sourceDocumentForPrefetches
(or its prefetch records) viasourceSnapshotParams
?Pros: It might be consistent with the existing decisions whether we should pass sourceDocument-related informatio n (
sourceSnapshotParams
orsourceDocumentForPrefetches
) or notCons?: this means not passing
sourceDocumentForPrefetches
infinalize a cross-document navigation
. IIUCsourceDocumentForPrefetches
will be still passed for ordinal cross-document navigations via navigate -> attempt to populate the history entry's document -> creating navigation params by fetching, even if we don't passsourceDocumentForPrefetches
via navigate ->finalize a cross-document navigation
though (I'm not sure the differences between the two paths, but probably the path via attempt to populate the history entry's document is the primary one?).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay; I got sick :(.
Hmm, I'm not sure. Mostly, sourceSnapshotParams and initiatorToCheck are used for security checks which (for some reason) browsers decide to not perform on reloads. The only thing that's kind of similar to how sourceDocumentForPrefetches is used is sourceSnapshotParams's fetch client, which is used to determine referrer and such. (E.g. for reloads, it always looks like the page is reloading itself, according to the
Referer
header.)Sorry, I realize I was misleading in what I said earlier. The paths are:
push/replace navigation:
navigate
->attempt to populate
->finalize a cross-document navigation
->apply the history step
. Inapply the history step
, targetEntry's document will be present, because of the earlierattempt to populate
step.reload navigation:
reload
->apply pending history changes
->apply the history step
->attempt to populate
. This time we reachattempt to populate
fromapply the history step
, because targetEntry's document state's reload pending is trueback/forward navigation, bfcache:
traverse the history by a delta
->apply the history step
. Inapply the history step
, targetEntry's document will be present, because bfcache.back/forward navigation, non-bfcache:
traverse the history by a delta
->apply the history step
->attempt to populate
. This time we reachattempt to populate
fromapply the history step
, because targetEntry's document is null, because no bfcache.Does that make sense? Feel free to grab me in person or in realtime if it doesn't; I know this stuff is complicated and I don't want to be confusing about it again.
So, I think your idea of putting sourceDocumentForPrefetches or the prefetch records in source snapshot params mostly works, and feels elegant. The consequence would be that reloads can only use prefetch records from their own document though, e.g. if you had this setup:
a.html
in an iframea.html
frames[0].reload()
then the prefetch would not be used. Maybe that's fine, because it's congruent with how the fetch client is set to
frames[0]
instead of to the parent?Another elegant part of putting the prefetch records (not sourceDocumentForPrefetches) in source snapshot params is that if we start storing the prefetch records on a wider scope, per #266, it will not change very much: it will just change the snapshotting call to grab them from a different place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, thank you for inputs and clarifications! Then I'll draft the spec to put prefetch records to source snapshot params.
I'm also less sure about reload's behavior here, but I feel we can prioritize (at least for now) the elegance/consistency of the spec architecture by putting the prefetch records to source snapshot params, and then later (after #266) we can revisit the reload behavior if actually needed in the wild.
If we make prefetch records scoped by network partition keys, I imagine prefetch records would be partitioned by the result of
determine the network partition key given request’s client
(becausesourceDocumentForPrefetches
basically corresponds to source snapshot params' client), while HTTP caches for navigation requests are partitioned by the result ofdetermine the network partition key given request’s reserved client
, which is perhaps simple.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to use source snapshot params.