Behavior of Fetch Request Caching
Answered
Siamese Crocodile posted this in #help-forum
Siamese CrocodileOP
Hello! I'm posting this to ask a question about the caching behavior of fetch requests in my Next.js 14.2.5 project.
Let's say I have a dynamic route [slug] that calls an API on the server side. If I set cache validation for 15 minutes, will the first dynamic route [slug] generated on the server side cause all other dynamic routes [slug] generated within the following 15 minutes to reuse the same API call?
Thanks !
Let's say I have a dynamic route [slug] that calls an API on the server side. If I set cache validation for 15 minutes, will the first dynamic route [slug] generated on the server side cause all other dynamic routes [slug] generated within the following 15 minutes to reuse the same API call?
Thanks !
Answered by B33fb0n3
if there is a dynamic page and only the one fetch request does have the revalidation time of 15 minutes, then the page itself will still be dynamically served, but while generating that dynamic response the server takes the cached result from the fetch
3 Replies
@Siamese Crocodile Hello! I'm posting this to ask a question about the caching behavior of fetch requests in my Next.js 14.2.5 project.
Let's say I have a dynamic route [slug] that calls an API on the server side. If I set cache validation for 15 minutes, will the first dynamic route [slug] generated on the server side cause all other dynamic routes [slug] generated within the following 15 minutes to reuse the same API call?
Thanks !
if there is a dynamic page and only the one fetch request does have the revalidation time of 15 minutes, then the page itself will still be dynamically served, but while generating that dynamic response the server takes the cached result from the fetch
Answer
Siamese CrocodileOP
Oh ok thanks a lot !
sure thing