How to prevent fetching data on the server if the client already has the needed data?
Unanswered
Crazy ant posted this in #help-forum
Crazy antOP
I have a list of products on a page /products. My queryClient contains each element's data in its own cache. When the user clicks on the item, the /products/[id] page opens.
What is the best way to prevent fetching data on a product page and use cached data? But if the user reloads the page, the product page does fetch the data.
For example, Nuxt.js has middleware and you can use stored data instead of fetching it. How to do this in Next.js ?
What is the best way to prevent fetching data on a product page and use cached data? But if the user reloads the page, the product page does fetch the data.
For example, Nuxt.js has middleware and you can use stored data instead of fetching it. How to do this in Next.js ?
5 Replies
Blue orchard bee
It's worth noting that if you use a development server (if I recall correctly), Next.js will always revalidate cached data.
And if you need to invalidate the data somehow, you can check the docs for available options.
Blue orchard bee
I recall the cache worked like this for Pages Router, not sure if it's the same for App Router.