0

I am having a simple markup.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="prefetch" href="page2.html">
    <link as="script" rel="prefetch" href="./src/script2.js">
</head>
<body>
    <p>Let's check</p>
    <a href="page2.html">Go to page 2 where script2 is there</a>
    <script src="./src/script1.js"></script>
</body>
</html>

Here I am prefetching the second script script2.js. It is prefetched successfully but when I click on page 2 link where I have my script tag script2.js, again script2 is downloaded it is not taking it from prefetch cache.

Here is the page2.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p>This is page 2</p>
    <script src="./src/script2.js"></script>
</body>
</html>
Aakash_Sardana
  • 232
  • 1
  • 6

1 Answers1

1

Had similar issue and the cause for me was that I had disable cache enabled in Google Chrome.

You can see how to disable/enable caching in Chrome DevTools on this answer https://stackoverflow.com/a/7000899/2992661

Dean Whitehouse
  • 839
  • 1
  • 7
  • 22
  • I am also facing the same issue. But in my case disable cache option is not enabled then also perfecting is not working. Any other option? – Ashish Shukla Mar 18 '21 at 09:53