Skip to content

Add Next Cache Option to Fetch #809

@backlineint

Description

@backlineint

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.
  • Use the cache option in the basic starter.

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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesttriageA new issue that needs triage

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions