-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use speculation rules prefetch/prerender when available
Speculation rules prefetch, currently only available in Chromium-based browsers, has some advantages over <link rel=prefetch>: * It stores the resources in a per-document in-memory cache, instead of in the HTTP cache, which can be slightly faster. * Because it has its own cache, it is not disabled by HTTP caching headers like Vary or Cache-Control. * It is automatically integrated into various user-respectful browser settings like Data Saver, Battery Saver, and memory pressure monitoring. * It has better cross-site support than <link rel=prefetch>, including the nonstandard as=document variant, because it disables itself if the destination site has cookies, whereas <link rel=prefetch> can cache the wrong version of the document (the version without cookies). * It shows up nicely in the DevTools speculative loads panel. The implementation strategy is to just insert a <script type=speculationrules> element, with a single list rule pointing to the target URL, instead of inserting the corresponding <link rel=prefetch> element. Additionally, we add the ability to configure prerendering, instead of prerendering, via the data-instant-specrules=prerender attribute. (Use of speculation rules can also be turned off, via data-instant-specrules=no.) Prerendering is more complex and risky, but can give a significant speed boost. More information on speculation rules prefetch and prerender is available at https://developer.mozilla.org/en-US/docs/Web/API/Speculation_Rules_API. When speculation rules are not available, we fall back to <link rel=prefetch> as usual.
- Loading branch information
Showing
6 changed files
with
47 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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