I had an issue where the app was making a lot of calls every time I changed pages then I add the cachelife function from cachecomponents and it stopped calling it as much. I'm still waiting for it to update, Hopefully I'll figure out the best way to cache to save money but also update regularly.
Here's the function that I used to cache in NextJS
import {cacheLife} from "next/cache";
'use cache'
cacheLife('days')
This function has to be used inside of a function to cache the function results. Sometimes caching will make some weird errors if the function returns something from server to client, but you'll just have to experiment a bit with it when you try to implement.
In my experiemntation I've discovered that what's returned by the function is saved to ram, this is good to know if you're running your app in a container where you need to plan out CPU and Memory usage.
This can also cause some weird things with AWS Cloudfront, in my experience it will always use the max cache setting in the cache profile set for the Cloudfront CDN. I think one of the headers that Cloudfront uses that's set by the cachelife function is longer so it can reuse the cache while it reruns the function.