Replies: 11 comments 3 replies
-
agree, nobody wants to DDOS their backend |
Beta Was this translation helpful? Give feedback.
-
I am wondering if this is the intended behavior. Imagine that the user hovers over the link, but not perform the navigate. And then the prefetched data get outdated. So once the user hover again, the data should be re-prefetched by then. |
Beta Was this translation helpful? Give feedback.
-
Maybe. I wasn't sure if this was not intentional behavior. I considered this as a feature because of the last point, which changes the behavior of the component and in my opinion needs confirmation from maintainers. |
Beta Was this translation helpful? Give feedback.
-
Actually, I am considering introducing a 10ms/20ms delay before prefetching (for onMouseEnter only, onTouchStart doesn't need that). This should prevent unwanted prefetches. |
Beta Was this translation helpful? Give feedback.
-
@trompx has a similar idea |
Beta Was this translation helpful? Give feedback.
-
Hi, as mentioned by @SukkaW this is intentional since with ISR the content could have been updated since it was prefetched due to being in the viewport so we attempt an additional optimistic prefetch on hover to allow getting fresh content. In most cases this will probably be a 304 which is a very minimal request (the payload body is not sent) and not expensive for the server to handle. If you aren't leveraging ISR and know the content won't change and would prefer stale content always be used you can disable this under an experimental config already |
Beta Was this translation helpful? Give feedback.
-
Any news regarding this? |
Beta Was this translation helpful? Give feedback.
-
I am about to wake my previous PR #40310 up (the PR is currently conflicting with the canary branch, I will start working on it ASAP). |
Beta Was this translation helpful? Give feedback.
-
I disable the prefetch on all links because my server is tired. 😂 |
Beta Was this translation helpful? Give feedback.
-
If you're on Next 13 and you have a middleware, this may be the middleware prefetching data (especially if the returned data is an empty object). Check this thread out: #44596 |
Beta Was this translation helpful? Give feedback.
-
I see that in the network tab these requests have status code 304 (Not Modified). Quoting MDN:
If I'm reading that right and my knowledge is on par, this means that the browser is serving this data from its cache and the server will never receive this request. Based on the HTTP caching rules in-browser, the browser will know when to consider any data in its cache to be stale and refetch the link accordingly. |
Beta Was this translation helpful? Give feedback.
-
Describe the feature you'd like to request
Idea: reduce the HTTP requests count that
next/link
generates when hovering over a link.My thoughts:
Describe the solution you'd like
Respect next/link prefetched cache on hover.
Describe alternatives you've considered
prefetched
Beta Was this translation helpful? Give feedback.
All reactions