-
Notifications
You must be signed in to change notification settings - Fork 22.5k
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
Correct Speculation Rules HTTP Status code support #35624
Correct Speculation Rules HTTP Status code support #35624
Conversation
Preview URLs (comment last updated: 2024-08-28 16:46:19) |
Servers can respond based on this header, for example, to log speculative load requests, return different content, or even prevent speculative loading from happening. If a non-success response code is returned (any HTTP status other than 200 or 304), then the page will not be prefetched/prerendered. This is the easiest way to prevent speculative loading, although it is usually a better approach to allow the prefetch/prerender, and use JavaScript to delay any actions that should only happen when the page is actually viewed. | ||
Servers can respond based on this header, for example, to log speculative load requests, return different content, or even prevent speculative loading from happening. If a non-success response code is returned (any HTTP status other than in the 200-299 range after redirects), then the page will not be prefetched/prerendered. In addition the 204 and 205 status codes also prevent prerendering (but do not prevent prefetch). | ||
|
||
Using a non-success code (for example a 504) is the easiest way to prevent speculative loading server-side, although it is usually a better approach to allow the prefetch/prerender, and use JavaScript to delay any actions that should only happen when the page is actually viewed. |
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.
Is 504 intentional here? This comment: WICG/nav-speculation#330 (comment) suggests 503, which seems closer in intent.
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.
Oh good spot! Fixed.
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.
This looks good to me. Approving but leaving open in case you want feedback from the people in WICG/nav-speculation#330.
Think we're good cause @jeremyroman (the spec author) LGTMed my similar change on the Chrome Docs. But he can give an LGTM comment if you prefer to wait for that? |
I'm happy if you are! |
Description
MDN previously incorrectly stated that status codes 200 and 304 were supported for Speculation Rules based on incorrect data in the Chrome documentation (that has since been corrected).
Motivation
We've had a developer report of confusion due to incorrect information:
WICG/nav-speculation#330
Additional details
See above links.
Details in spec
Related issues and pull requests