I want to prefetch a JSON resource and use it later in my JavaScript code when necessary.
I'm prefetching with:
<link rel="prefetch" href="/data.json" as="fetch">
But I don't know how to access this resource. As the data is loaded and cached, I thought that a fetch
request would use the cache, but it is making a second request to the server (that I would like to avoid).
// a second request is sent to server instead of using the cache
fetch('/data.json').then(console.log);