-
-
Notifications
You must be signed in to change notification settings - Fork 325
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
prefetch page context #1617
base: main
Are you sure you want to change the base?
prefetch page context #1617
Conversation
@brillout Any advice on this would be greatly helpful. Thank you in advance for your assistance. |
@usk94 I will have a look and reply after I'm finished what I'm currently working on. ETA (beginning) of next week. |
@brillout |
@usk94 Alright, let's do this! Have a look at Open question: do you think viewport prefetching makes sense for |
Thanks! I'll try it.
Are you concerned that, for example, it might be too aggressive in terms of saturating the network with too many API requests? For instance, in frameworks like Astro, when viewport prefetching is enabled, the priority of these requests is managed to be lower to mitigate potential network congestion. But even with that consideration, I agree that it might be too aggressive. I think starting with hover prefetching would be sufficient. |
Yes, that's expected. It only fetches the I was thinking whether we should also call Let me know if you think
Yes, and also overloading the server (its database and logs).
👍 We could also, eventually, add support for viewport prefetching for individual links that opt in using the
Indeed Astro seems to be using clever heuristics. If you want we can improve Vike's prefetching in a follow up PR after this one. I also have a couple of ideas for improving static asset prefetching. |
@Boeing787 (sponsor who requested this feature) Do you have any special wishes? Your use case is that you want data to be prefetched when the user hovers a on link, correct? |
@brillout correct, to load the pageContext |
…ntext._pageId` are mismatched
@brillout If I have the opportunity to contribute in the future, I'll make sure to double-check my code more thoroughly. I appreciate your guidance and support. |
No issues, we're all learning 🙂 |
e078730
to
4cd1fc9
Compare
resolve #246
This PR introduces a feature to prefetch
pageContext
(specifically focusing ondata
) when users hover over a link.To ensure efficient network usage, the prefetch operation includes a cooldown period to prevent it from being re-triggered too soon after the initial action.
And if the user hovers over multiple links,
pageContext
fetched for previous links can be used instead of being discarded.Users can configure this feature through
+config.ts
or by settingdata-prefetch-page-context
attributes directly on anchor tags.