unstable_cache not working during build
Answered
Giant resin bee posted this in #help-forum
Giant resin beeOP
I have a project where same data is needed in 5 pages and i want these pages to be render on build time with generate static params , so i wrap the fetch request in unstable_cache, now this cached function is being called onetime in layout and one time for page, so technically it is used 10 times (2*5 pages) but as it is wrapped in unstable_cache it should be called only one time but you can see following logs that it is calling 10 times, so cache is not working. Can you help me with this, this is the repo of code, please check data.js file in lib folder.
https://github.com/ahmedivy/countries-front-end-v2
https://github.com/ahmedivy/countries-front-end-v2
Answered by Toyger
and it shouldn't work, you can't use any cache during build.
if you want reduce calls on api you can download file to some local folder and read from here instead making fetch
you can make it with some prebuilt script, here is possible ways to implement some prebuilt logic https://github.com/vercel/next.js/discussions/17479
if you want reduce calls on api you can download file to some local folder and read from here instead making fetch
you can make it with some prebuilt script, here is possible ways to implement some prebuilt logic https://github.com/vercel/next.js/discussions/17479
1 Reply
Toyger
and it shouldn't work, you can't use any cache during build.
if you want reduce calls on api you can download file to some local folder and read from here instead making fetch
you can make it with some prebuilt script, here is possible ways to implement some prebuilt logic https://github.com/vercel/next.js/discussions/17479
if you want reduce calls on api you can download file to some local folder and read from here instead making fetch
you can make it with some prebuilt script, here is possible ways to implement some prebuilt logic https://github.com/vercel/next.js/discussions/17479
Answer