-
-
Notifications
You must be signed in to change notification settings - Fork 474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the way prefetched URLs are stored in the cache #641
Comments
Hi @migueltrias, By default, Barba prefetch links on mouseover, but you can customize this, see https://barba.js.org/docs/advanced/strategies/#Prefetch. Normally, it shouldn't prefetch again when mouseovering if you got the caching enabled. Thanks! |
hi @xavierfoucrier, |
Thanks for the feedback @migueltrias! I will take time to check this as soon as possible and let you know. |
Hi @migueltrias, After a quick check, this is related to absolute/relative URLs. import barba from '@barba/core';
barba.init();
// this will prefetch the page on click, and on mouseover
document.addEventListener('click', () => {
barba.prefetch('page.html');
});
// this will prefetch the page on click only
document.addEventListener('click', () => {
barba.prefetch('http://localhost/page.html');
});
|
Thanks for looking into this! My manual barba.prefetch() function is trying to load a "/" relative base url (like href="/collection"), not even specifying the absolute URL... I'm trying to find the difference between both calls but they look identical to me :S |
Hi @migueltrias, Calls may look identical, but cached URLs will be different:
You can simply fix this by giving an absolute URL to prefetch 😉 |
Hi,
I'm using Barba.prefetch() to prefetch a specific single URL that is a little bit heavy (I don't need to prefetch the other viewport urls, so I'm not using barba/prefetch), and I've realized that when mouseover the link with the exact same URL, it gets loaded again, so I'm loading it twice when it should do nothing as it's supposed to be prefetched already.
I've inspected both xhr loads and they are identical, it's just that it does it twice...
Is this a normal behaviour? If so, how to succesfully prefetch a url and avoid loading it again through mouseover?
Thanks
The text was updated successfully, but these errors were encountered: