HTML preload link not not working to load fetch

Viewed 479

I am preloading an html page using the link tag

<link rel="preload" href="/pages/test" as="fetch">

And then fetching it later using fetch

async function loadPage() {
  const html = await (await fetch("/pages/test")).text();
}
loadPage();

But two seperate requests are still being made. I have already tried the solutions here, but none of them worked for me.

1 Answers

rel="preload" should only be used to fetch a JSON or ArrayBuffer response and shouldn't be used to download an HTML page. Also include the crossorigin attribute to avoid duplicate requests.

Related