You can use rel=”prefetch” to download resources that may be needed soon. To prefetch pages, consider the Speculation Rules API. Another approach is to use a service worker to precache files needed later. These approaches are suitable when you are highly confident users will need the content, not for downloading the content behind every link in advance. Limitations include potentially wasted bandwidth, use of device resources, and the possibility that browsers will ignore prefetch hints. Avoid prefetching when users have enabled Save-Data.
Use browsing data to decide what to prefetch
Whether prefetching helps depends on whether the downloaded content is actually used later. If site analytics show that most users complete a particular workflow, consider fetching the critical resources needed to display subsequent pages in advance. A link’s presence on a page alone does not mean it is worth prefetching.
- Prioritize resources that are likely to be used, and prefetch only when necessary and when the connection is fast.
- Consider Quicklink’s approach: dynamically prefetch links when they enter the viewport rather than processing every link at once. This still does not guarantee users will click them.
- Disable prefetching when users prefer reduced data usage, so they do not use data for pages they never visit.
Resource prefetching is a hint, not a download guarantee
You can use rel=”prefetch” to hint that the browser should fetch images, stylesheets, and JavaScript in advance. For example, if a date picker will be used later, you can specify its script and stylesheet with as=”script” and as=”style”, respectively. You can also use JavaScript to add hints dynamically as users interact.
Browsers may make low-priority requests during idle time to reduce competition with resources for the current page. However, factors such as network quality and system preferences may cause hints to be ignored, so adding a prefetch hint does not guarantee that resources will be ready.
Understand the difference between page prefetching and prerendering
The reference material describes the Speculation Rules API used by Chromium browsers. It uses JSON rules to list target URLs and specify prefetch or prerender; rules can also be added dynamically. These rules are likewise only hints. According to the reference material, content prefetched through this API is stored in an in-memory cache, unlike the HTTP cache used by link prefetch.
Prerendering also processes the page and executes JavaScript in the background, potentially allowing the page to appear faster when users navigate to it. However, it has a higher computational cost and should be limited to pages users are very likely to visit.
For link prefetch, the reference material also generally recommends avoiding two types of content: cross-origin documents and personalized HTML generated dynamically after login. Cross-origin documents raise concerns about duplicate requests. Personalized HTML is typically not cached, so prefetching it can easily waste bandwidth.
Manage precaching together with versioning
A service worker can cache specified files using the Cache API during installation, making them available to pages it controls. For example, a product listing page could precache the CSS and JavaScript needed by product detail pages. The Cache API is managed through JavaScript and is not the same as the HTTP cache governed by Cache-Control headers.
With Workbox, a precache manifest can list files and version information to help remove outdated entries during updates. However, precaching still consumes bandwidth, storage, and CPU resources. If you are unsure whether resources will be used, precache fewer of them and rely on runtime caching for the rest.
Prefetching resources and pages: perspectives from across the web
How does a service worker's cache-only strategy access precached resources?
With a cache-only strategy, eligible resources are fetched from the network during service worker installation. After installation, requests for these resources are served only from the service worker cache, without accessing the network again. This can provide near-instant responses for cached resources, provided that the required resources have already been cached and the page is controlled by that service worker.
How should versions be specified in a Workbox precache manifest?
A precache manifest lists the files to cache along with version information. If a filename already contains a content hash, revision can be set to null. If the resource itself has no version identifier, a revision can be generated at build time. Workbox uses this information to track versions and remove outdated cache entries when the service worker updates.
Does legacy link prerender always render pages in the background?
Not necessarily. According to the reference material, starting with version 63, Chrome used NoState Prefetch for link prerender: it fetched the resources needed for a page without rendering the page or executing JavaScript. This is historical behavior and should not be assumed to reflect current behavior across all browsers.
References
- Assist the browser with resource hintsweb.dev — Source used in the article above.
- Prefetching, prerendering, and service worker precachingweb.dev — Discusses: How does a service worker's cache-only strategy access precached resources?; How should versions be specified in a Workbox precache manifest?



