Next.js Discord

Discord Forum

Caching data when using prisma

Answered
JM posted this in #help-forum
Open in Discord
JMOP
When I fetch data from DB using prisma, does the server component automatically cache that data? What happens? If there is any post about this, can you share it? thank you.
Answered by joulev
does the server component automatically cache that data
no
What happens
nothing is cached, it will just be like a normal computation step in the server component

you need to set up caching manually with segment-level caching (export const revalidate or export const dynamic) or with unstable_cache
View full answer

2 Replies

@JM When I fetch data from DB using prisma, does the server component automatically cache that data? What happens? If there is any post about this, can you share it? thank you.
does the server component automatically cache that data
no
What happens
nothing is cached, it will just be like a normal computation step in the server component

you need to set up caching manually with segment-level caching (export const revalidate or export const dynamic) or with unstable_cache
Answer