#Caching data among layouts

1 messages · Page 1 of 1 (latest)

prisma umbra
#

Hi, I am basically looking for the best way for avoiding the same request server-side when fetching the same data.

Basically, what Next.js RSC does with cache (I know, it's exported from React...).

I don't mind if it's a third-party library, I would just like to know if anyone has solved this in some way.

Thanks!

cobalt flint
#

you can use lru-cache for an in-memory cache, you can use Redis for an external storage for your cache which will work better if you have more than one instance of your app running (eg. serverless), some services have specific services too like Cloudflare Worker KV if you deploy to CF Workers or CF Pages

prisma umbra
#

Thanks Sergio!

My main aim is to do so on a per request-basis to avoid caching issue, as long as it's done and forgotten in the same request, that would be good to me. I'll look into that

lunar lantern