Confused
ajaydevopi opened this issue · 1 comments
Hello,
If I may ask the following... I am kind of a newbie and I have a hard time understanding how this app works.
I also use Vercel and I am interested in making API calls / fetching data. Also I use NuxtJS (universal) of course.
My aim is this:
< With SWR, components will get a stream of data updates constantly and automatically.
And the UI will be always fast and reactive. >
First I thought you used this SWR plugin built by Vercel... SWR - Vercel - but that is a React Hook and I do not find this plugin in the package.json and not in the plugin dir.
Then I thought that you used "The Fetch Hook"... The Fetch Hook - I guessed that is also not the one.
Then I found "OhMyFetch"... OhMyFetch - ...
Well, I am confused, so sorry.
So how does it work to get a stream of data updates constantly and automatically with NuxtJS and Vercel?
"The Fetch Hook" is called on server-side apparently also. But I do not find a big JSON file with all compiled articles you pulled in. So I am double confused. Is the fetched data only available client-side (so no JSON file, no database, nothing)?
I am sorry again for the silly questions, but if you could clarify then that would be very nice of you. Thank you on forehand.
@ajaydevopi SWR caching can be implemented in a number of different ways.
-
One way is client-side, using a library like swrv which I think is probably what you're interested in.
-
A second way is server-side (in the case of Vercel) is to use the
stale-while-revalidate
cache header to enable a SWR cache strategy, which guarantees a quick response to requests at the expense of potentially stale data.
And of course these two approaches can be used in conjunction with each other. However, this project at the moment uses purely the latter approach, with data being fetched on initial load and on page navigation. You can see more about how data is fetched lazily on client-side here.