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
fix(gatsby-link): don't prefetch same page #28307
fix(gatsby-link): don't prefetch same page #28307
Conversation
This looks great! Thanks for doing this so quickly @wardpeet ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks cleaner, more dry with _prefetch() and appears that it will solve the bug 😄 Woo 🎉
We can hotfix it :) |
Awesome :D |
* fix(gatsby-link): don't prefetch same page * test prefect intersection-observer Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com>
* fix(gatsby-link): don't prefetch same page * test prefect intersection-observer Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com> (cherry picked from commit 3666130)
@wardpeet, @TylerBarnes PR backporting this to 2.27 release - #28313 |
Published in |
Thanks @vladar ! |
Description
When prefetching a url that's already being fetched can end up in a race-condition where the browser looks into it's prefetch cache.
You can end up with stale data.
How can this happen?
If you have a gatsby-link component with the same url as the current page.
This is an issue when using wordpress preview
I've added tests to make sure we test this behaviour
On the demo you see that the prefetch cached network request wins over the new request