When are fetch POST requests cached?
Unanswered
Ratonero Mallorquin posted this in #help-forum
Ratonero MallorquinOP
I humble seek answers from the magical black box that is NextJS caching!
Documentation states that:
and
My understanding then is that if you use fetch requests with the POST method during the rendering of a
Is this correct by default?
If so, then what differentiates the caching?
Imagine you are POST-ing to an API, for example search parameters and settings to a search API, as a JSON request BODY.
If your request object changes search terms in a nested property, will the fetch caching mechanism be smart enough to differentiate this?
Documentation states that:
By default, Next.js automatically caches the returned values of fetch in the Data Cache on the server.
and
However, there are exceptions, fetch requests are not cached when:
Used inside a Route Handler that uses the POST method.
My understanding then is that if you use fetch requests with the POST method during the rendering of a
page.tsx (so NOT a route handler) then you WILL get caching within that fetch request.Is this correct by default?
If so, then what differentiates the caching?
Imagine you are POST-ing to an API, for example search parameters and settings to a search API, as a JSON request BODY.
If your request object changes search terms in a nested property, will the fetch caching mechanism be smart enough to differentiate this?