Next.js Discord

Discord Forum

How to cache functions in server side?

Unanswered
Netherland Dwarf posted this in #help-forum
Open in Discord
Netherland DwarfOP
Hello, i was looking at next.js doc but i only see caching for using fetch. I have an async function called getImages that uses file system to get images in public folder and get the byte64 value of them and returns the byte 64 images in an array. I want this function to only be run once in the server component and whenever user refreshes the page no request is ever made again.

I am using react cache to do this, but i not sure if this is the right way. How can i do this?

0 Replies