Prefetch - MDN Web Docs Glossary: Definitions of Web-related terms 编辑
Prefetching is when content is downloaded in the background, this is based on the assumption that the content will likely be requested, enabling the content to load instantly if and when the user requests it. The content is downloaded and cached for anticipated future use without the user making an explicit request for it.
DNS Prefetching
Domain lookups can be slow, especially with network latency on mobile phones. They are most relevant when there are a plethora of links to external websites that may be clicked on, like search engine results, DNS prefetching resolves domain names in advance thereby speeding up load times by reducing the time associated with domain lookup at request time.
<link rel="dns-prefetch" href="https://example.com/">
Link prefetching
Link prefetching is a performance optimization technique that works by assuming which links the user is likely to click, then downloading the content of those links. If the user decides to click on one of the links, then the page will be rendered instantly as the content has already been downloaded.
The prefetch hints are sent in HTTP headers:
Link: ; rel=dns-prefetch, ; as=script; rel=preload, ; rel=prerender, ; as=style; rel=preload
Prefetch attribute value
Browsers will prefetch content when the prefetch <link>
tag directs it to, giving the developer control over what resources should be prefetched.
<link rel="prefetch" href="https://www.example.com/solutions" />
See also
- defer
- async
- preload
- page prediction
- lazy loading
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论