What’s the optimal caching strategy for data that uses params without generateStaticParams? #85790
Replies: 3 comments 1 reply
This comment was marked as off-topic.
This comment was marked as off-topic.
-
|
I think the problem here is that a serverless deploy doesn't typically have an in-memory API across instances, so |
Beta Was this translation helpful? Give feedback.
-
|
If you need persistent or shared caching across deployments, you can consider one of these approaches: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a question about the sample code in the documentation.
In the sample, generateStaticParams isn’t used. Therefore, my understanding is that getProduct cannot be evaluated at build time, making the route dynamic — which means "use cache" wouldn’t take effect. Is that correct?
When I tested this locally, caching seemed to work, but after deploying to Vercel, the cache was not applied.
Additionally, since the sample code doesn’t use generateStaticParams, params behaves as runtime data. Because of this, I don’t see why a connection would be required — yet it’s explicitly specified in the example. Could you explain the reasoning behind that choice?
To summarize my understanding:
Demo
use cache: remote: https://next-16-guide.vercel.app/dynamic-paramsuse cahce: https://next-16-guide.vercel.app/dynamic-params-not-remote-cacheReference:
https://nextjs.org/docs/app/api-reference/directives/use-cache-remote#mixed-caching-strategies
Thank you for your suppoort!
Beta Was this translation helpful? Give feedback.
All reactions