next-drupal icon indicating copy to clipboard operation
next-drupal copied to clipboard

Add Next Cache Option to Fetch

Open backlineint opened this issue 1 year ago • 1 comments

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 JsonApiWithNextFetchOptions type to include this cache option.
  • Update fetchOptions type (or one of the types that it extends) to include this cache option.
  • In the nextDrupal class, update all calls to fetch to pass the cache option as part of the init object 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.

backlineint avatar Oct 22 '24 16:10 backlineint