Not sure if my request are being cached.
Unanswered
LeonN posted this in #help-forum
LeonNOP
I'm fetching data on a server component on the "school/[id]" route. I'm using a a custom function that wraps the default fetch and abstracts some stuff for me. This functions are using force-cache, as you can see. I also attatched the myFetch function to add some context.
The thing is that when I watch the browser network section, every time I navigate to a page where it uses the same fetch and id, a new network resquest is being made. However, in my api written in Nest js (I know I can use route handlers, but i want to use Nest for my backend), I'm loggin every time that endpoint is being reached. And the shows only that only the first request is being reached, the other request are not making the call to my API. Here comes my doubt, is my request being cached or not? Since my API log show one thing, and the network request show another one.
The thing is that when I watch the browser network section, every time I navigate to a page where it uses the same fetch and id, a new network resquest is being made. However, in my api written in Nest js (I know I can use route handlers, but i want to use Nest for my backend), I'm loggin every time that endpoint is being reached. And the shows only that only the first request is being reached, the other request are not making the call to my API. Here comes my doubt, is my request being cached or not? Since my API log show one thing, and the network request show another one.
resquest: school not cached
2 Replies
yes, its being cached and it only hit your API once
the first time you visit the site, the data is cached on next server, on following requests, the website fetch to the next server, not your backend and take the cached data from there
the first time you visit the site, the data is cached on next server, on following requests, the website fetch to the next server, not your backend and take the cached data from there
here's more info about how it really works
https://nextjs.org/docs/app/building-your-application/caching
https://nextjs.org/docs/app/building-your-application/caching