next-drupal
next-drupal copied to clipboard
Add Cache (Tags/Revalidate) opions to getResource/getResourceCollection Calls in Basic Starter Page Templates
Package
basic-starter
Describe the feature request
https://github.com/chapter-three/next-drupal/pull/784 introduced revalidate options for the fetch methods used by the Next Drupal client, including tags. But currently the page templates in our starters don't use them when making fetch requests.
Describe the solution you'd like
A little bit on the fence here, but it seems like the revalidation option might be the best starting point, with tags being an option that is easy to enable.
-
In app/slug/page.tsx: ** Create a new const
tagbased on the data returned from translatePath. The value should be of the typeentity.type:entity.id** In the options for getResource, pass a next object with: *** Revalidate set to some default value (3600?) *** Tags set to the value of thetagconst. This should be commented out by default. -
In app/page.tsx: ** In the options for getResourceCollection, pass a next object with: *** Revalidate set to some default value (3600?) Note: it isn't clear to me how to efficiently use tags to invalidate this articles list. We won't know the individual node ids until we get the response back, and the only grouped tag I see from jsonapi is 'node_list' which seems to broad. As a result, invalidation only seems like the best place to start.
Describe alternatives you've considered
Defaulting to tags instead of revalidate/paths. Could make this change if we hear positive feedback related to the new tag based revalidation features.