next-drupal
next-drupal copied to clipboard
Add Next Cache Option to Fetch
Package
next-drupal (NPM package)
Describe the feature request
Currently it is not possible to specify the cache option when using fetch with the Next Drupal client.
Next.js 15 increases the priority for this as it flips the caching semantics to be uncached by default: https://nextjs.org/blog/next-15#caching-semantics Although I'm not sure how much of a problem this is in practice as the docs state:
As a convenience, it is not necessary to set the cache option if revalidate is set to a number.
So that would cover path based revalidation with revalidate. I would hope that the same thing happens if you use the tags option, but would have to test to confirm. Regardless it is still confusing for us to not have a way to directly control this cache option that Next exposes.
Describe the solution you'd like
- Update the
JsonApiWithNextFetchOptionstype to include thiscacheoption. - Update
fetchOptionstype (or one of the types that it extends) to include thiscacheoption. - In the nextDrupal class, update all calls to fetch to pass the cache option as part of the
initobject if provided.
Additional context
This is starting to make our withCache option even more confusing. I continue to wonder if that should be deprecated in the future.