-
Notifications
You must be signed in to change notification settings - Fork 78
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
Mechanism to skip edge data fetching on client navigation #93
Comments
Why use getEdgeProps if you want to render on the client? |
Because I want to have SSR when the URL is directly accessed. |
So basically, you want the first load to be served from cache then, skip getEdgeProps on navigation and run it on the client? |
Right. so basically going directly here: The work-around I have right now is to take a static HTML page and use |
Wouldn't it be easier then to do a hard navigation then? |
I'm sorry, I don't understand your question. |
I propose to perform a hard navigation when user clicks the link. On first load, page will be rendered with getEdgeProps, upon additional navigations to that route, pages will be served directly from cf cache. |
That's what already happens, it just does it in the background with XHR. I'm saying I don't want it to hit CF at all. :) |
errr... let me be more clear. Right now, the behavoir is that if you have Since I'm hitting a third party (and already have their URL). I need to be able to skip Cloudflare completely and hit the 3rd party directly from the user's browser. |
Some other users cases in vercel/next.js#11897 are when you already have the props locally for the page transition and there is no need to make an XHR request to get them. There is no way to stop that request from happening in @flareact or Next.js currently. In other words, you could be making a completely useless HTTP request and blocking the navigation on that request. :( |
I think that this only happens if you use flareact Link with prefetch on. When landing on a cached route(directly or with hard navigation) you just get rendered html from cache(with props in the the flareact object, don't know why, there's a discussion about that). |
No.
Again, that is not a work around. If I hard navigate the user, Flareact will call |
You looking network in dev? I'm looking at my deployed project, no props fetched by xhr, only html response. I don't understand what you mean by "not make a request to cf at all". The response coming from a cf worker, you always hit cf. If you can't cache 3rd party api, how you want to use getEdgeProps? Without caching? Why not useEffect then? Or you want that only the first response be cached? |
Take a look at this function: flareact/src/client/page-loader.js Lines 79 to 83 in 02cd98a
which is called by: Line 55 in 02cd98a
I want to prevent that from happening. The only way (looking at the code) is by not having |
Another option is to hard navigate to a dynamic route url, SSR will be dynamic based on that url |
I've said this three times, but it's really not, it does the same exact thing here: Line 109 in 02cd98a
If you go to https://flareact.com/ and open up the "Network" in dev tools you can see the XHR requests to get the props (in JSON) as you navigate the documentation. |
You mean this? |
The XHR is going to happen whether it is prefetched or not. Prefetching just makes it happen before you click the Link. At some point, the props must be fetched. This task is to skip fetching them completely (optional, of course). As I mentioned before, #92 would probably fix this anyways. |
Unless you DON'T use |
🤦 If you don't use Link, you'll do a hard page transition (which will reload all the JS, but that is a sidepoint), which will hit the worker, and call |
In other words, the props are cached either way, if it's returned in JSON or in HTML, that is irrelevant. What I'm trying to do is not make a request to Cloudflare at all. I'm not sure why this is so hard to understand. |
Correct. But all the heavy lifting happens only once. Upon following hits to that route, your client served with rendered html and the usual js bundle |
What's hard to understand(for me) is why using getEdgeProps in the first place if you don't want to make requests to cf. |
To put this another way, I need to say Meaning it will happen every time (which is exactly what happens with JSON format too)
I want to use it when a person goes to the page directly (return HTML & SSR) but not use it when someone navigates on the client (see the updated title of this issue) |
I saw something about passing isWorker parameter to getEdgeProps(cant find it, sorry). |
Clone of vercel/next.js#11897
Effectively there is no way to do both getEdgeProps() for data fetching when the page is rendered, but not do this step from the client if the user is changing routes. Currently what happens is the user makes an XHR request for the props (which are returned in JSON)
This is a blocking issue for @chickaree to adopt @flareact because it's actually takes longer to render the props on the edge than on the client (Cloudflare Workers are missing DOMParser, so the parsing has to be forwarded to a Node.js server).
As I mentioned in vercel/next.js#11897 (comment), I think this could be resolved by #92.
The text was updated successfully, but these errors were encountered: