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

Cache tags based revalidation

Open lauriii opened this issue 2 years ago • 2 comments

The current revalidation logic in next_extras has some potential scalability issues since it's using paths for revalidating pages. It's complex to use this approach with lists and entity references since currently those would have to be added manually to the revalidation logic. If we implemented that while using the path based approach, with larger sites, this could lead into hundreds or thousands of requests.

Since Drupal provides cache tags for all requests, I'm wondering if we could utilize cache tags for the revalidation.

lauriii avatar Jun 15 '22 12:06 lauriii

I agree. 💯

I tried to outline a possible implementation here (this was before on-demand ISR): https://twitter.com/shadcn/status/1478417144924676096

Unfortunately Next.js only supports path based revalidation for now.

I'm also interested in using cache tags from Drupal. I'm looking into a solution where we could re-use the cache tags from Drupal in Next.js and use those for invalidation.

I'll report back.

shadcn avatar Jun 15 '22 13:06 shadcn

Adding links to some ongoing discussions:

https://github.com/vercel/next.js/discussions/34585 https://github.com/vercel/next.js/discussions/34567

shadcn avatar Jun 15 '22 13:06 shadcn

After a few days of installing next.js + Drupal and getting familiar with most things this was the first major thing I was curious to see if it was planned, or something was on the line. I see there's a potential limitation on next.js , right?

Anyway, I want to bring in something I used for purging CF without having enterprise (which is where tag invalidation is present): https://www.drupal.org/project/purge_queuer_url

Maybe a purge plugin can be implemented for the revalidation paths or use the module/logic some other way.

hanoii avatar Jan 17 '23 02:01 hanoii

@hanoii Yep. Still not available. But it's being worked on. For now, what I'm doing is using a custom Revalidator plugin that reads the entity tags and then revalidate the paths (this assumes that the Next.js paths to revalidate are deterministic).

https://next-drupal.org/docs/revalidator

shadcn avatar Jan 17 '23 06:01 shadcn

Would you be able to share that custom revalidator of yours? How do you translate tags to paths?

hanoii avatar Jan 17 '23 13:01 hanoii

@shadcn just a quick check in to see if there's any chance you can share that custom revalidator? Thanks!

hanoii avatar Jan 31 '23 21:01 hanoii

Still trying to see if this progressed a bit, saw

https://twitter.com/shadcn/status/1629533541183651842 And https://vercel.com/blog/vercel-cache-api-nextjs-cache

Is this going to be a vercel only thing?

Any chance you can share your custom revalidation work?

hanoii avatar Mar 31 '23 17:03 hanoii