Navigating to a page that was prefetched with <link rel="prefetch"> re-downloads it
Categories
(Core :: Networking: Cache, defect, P3)
Tracking
()
People
(Reporter: adieulot, Unassigned)
References
(Blocks 2 open bugs)
Details
(Whiteboard: [necko-triaged][necko-priority-next])
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.96 Safari/537.36
Steps to reproduce:
- Add <link rel="prefetch" href="2.html"> dynamically on a page
- Click on a link to 2.html
2.html doesn’t have any cache header.
Actual results:
The page got prefetched when the link element was added. When I click on the link the page is downloaded again.
Expected results:
When clicking on the link the page should not be re-downloaded.
Comment 1•6 years ago
|
||
Can you please post the http headers for 2.html ?
Reporter | ||
Comment 2•6 years ago
|
||
HTTP/1.1 200 OK
Content-Type: text/html
Date: Tue, 12 Feb 2019 21:27:08 GMT
Connection: keep-alive
Transfer-Encoding: chunked
Comment 3•6 years ago
|
||
I think that the caching time is pretty short because the Date header is not far in the past.
I think the document is already expired when you open it.
Comment 4•6 years ago
|
||
Dragana, do you know who on our team knows prefetch the best? I can take a look if you don't.
Matti, your theory is likely correct. I don't recall any enforcement of use in the prefetch code, so this depends on cache reusability setup by the server, probably.
Likely candidate for an INVALID.
Reporter | ||
Comment 5•6 years ago
|
||
Sorry for not providing the use cases in the first post. I’ll do so now.
The thing is that prefetch requiring cache headers makes it much less useful (and is not what Chrome is doing).
On Chrome’s behavior:
https://medium.com/reloading/preload-prefetch-and-priorities-in-chrome-776165961bbf
prefetch requests are maintained in the unspecified net-stack cache for at least 5 minutes regardless of the cachability of the resource.
So prefetched requests in Chrome are available for 5 minutes after prefetch.
On the usefulness of prefetching without cache headers:
Two recent JS library make sites much faster without a lot of effort in Chrome, using prefetch, and they’re popular.
https://instant.page/ “Make your site’s pages instant in 1 minute” (my library) prefetches on mouseover/touchstart right before a click happens. It was released 5 days ago and got 1200 points on Hacker News.
https://github.com/GoogleChromeLabs/quicklink prefetches links in the viewport. It was released two months ago and amassed 5900 stars on GitHub.
Users really respond to speed (see first footnote on instant.page) and prefetch makes it possible to noticeably improve the user experience very easily, but only for browsers that reuse prefetched requests without cache headers.
Comment 6•6 years ago
|
||
We need to do refactoring of prefetch. Currently it depends on cache.
Reporter | ||
Comment 7•6 years ago
|
||
Another use case for this is to make an extension to prefetch pages, like FasterChrome.
Updated•2 years ago
|
This is also covered here: https://timkadlec.com/remembers/2020-06-17-prefetching-at-this-age/
Reporter | ||
Comment 9•2 years ago
|
||
We need to do refactoring of prefetch. Currently it depends on cache.
— April 2019
Has this happened?
Comment 10•1 year ago
|
||
Has this been fixed yet? Thank you.
Updated•1 year ago
|
Updated•1 year ago
|
Comment 11•1 year ago
|
||
I think this is still a problem. I think prefetching a resource for navigation wouldn't work at all right now
Comment 12•1 year ago
|
||
For pages that don't have cache headers, we can either have a metadata entry that says it's a prefetch, so we check that when determining if the cache entry is valid, or we can use forceValidFor to force the cache entry to be valid.
Comment 13•2 months ago
|
||
(In reply to Alexandre Dieulot from comment #9)
We need to do refactoring of prefetch. Currently it depends on cache.
— April 2019Has this happened?
Alexandre, thank you for your continued interest in this bug. I am not sure if we will do a full refactor, but might atleast try Valentin's approach in Comment 12.
To understand the priority for this fix, do you have any numbers on how common is for us to get the prefetch requests without cache headers?
Thanks
Reporter | ||
Comment 14•2 months ago
|
||
(In reply to Sunil Mayya from comment #13)
To understand the priority for this fix, do you have any numbers on how common is for us to get the prefetch requests without cache headers?
The vast majority of prefetch requests are done without cache headers. Prefetching mostly happens through JS libraries (such as my own instant.page, https://github.com/GoogleChromeLabs/quicklink, Flying Pages) that website owners plug simply into their websites, with zero thought towards crafting elaborate cache headers.
Description
•