(nextjs14) react cache usage with revalidation question
Answered
Basset Fauve de Bretagne posted this in #help-forum
Basset Fauve de BretagneOP
Hey community!
I'm doing a query to my database via Drizzle ORM and I would like to cache this using a static revalidation of X seconds. I'm using cache react and I'm returning a timestamp to check if its working properly. When building and starting (npm run build + npm run start to test prod deployment) the server on my machine every time I hard refresh the page I'm getting always a new timestamp value. I'm doing anything wrong?
Thanks in advance guys!
I'm doing a query to my database via Drizzle ORM and I would like to cache this using a static revalidation of X seconds. I'm using cache react and I'm returning a timestamp to check if its working properly. When building and starting (npm run build + npm run start to test prod deployment) the server on my machine every time I hard refresh the page I'm getting always a new timestamp value. I'm doing anything wrong?
Thanks in advance guys!
Answered by Basset Fauve de Bretagne
I think I got it! Using the search params in the page is making it dynamic, which is disabling the cache capabilities. One way would be to keep it dynamic and use unstable cache or just use a client component to read the params (wrapped by suspense). What do you think?
1 Reply
Basset Fauve de BretagneOP
I think I got it! Using the search params in the page is making it dynamic, which is disabling the cache capabilities. One way would be to keep it dynamic and use unstable cache or just use a client component to read the params (wrapped by suspense). What do you think?
Answer