-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[⚡ Feature]: Add KV (or custom) support for revalidateTag (next/cache) #529
Comments
I actually originally wanted to let people opt in to other storage mechanisms by the presence of the binding being detected, e.g. The general idea that was settled upon would be to require people use a separate cache interface using the Personally, I would actually quite like to add the binding-presence based approach for things like KV/R2/D1, and can quite easily revive that, but I'm not sure whether @dario-piotrowicz would be okay with that approach. I would also note that Vercel's data cache is regional, so using the cache api is a rather similar experience. |
Hi everyone! I just released a Next.js based website in production on Pages and had a lot of headaches because the data cache is regional. In short terms, news being added to the website didn't show up at all in the homepage because the origin server was triggering revalidateTags and revalidatePaths in just one region. Having a distributed cache would solve this. You're right @james-elicx, on Vercel the data cache is regional as it is on Cloudflare Pages, but there's an important difference (from the docs, my emphasis):
So, to better replicate the Vercel model, there should be at least a way to revalidate the data cache globally. Using KV is the obvious way to do this on Cloudflare. In the future a hybrid approach (use Cache API primarily with a short expiration and reading through to KV for global consistency) could be beneficial for really high scale apps. I understand the hesitations about using an Also, about the |
The main part of the problem is that the path provided for |
Hi @juanferreras, sorry for the late reply 🙂 I think we agreed with @james-elicx that we can try to go with an approach in which the cache handler can be configurable via the standard There's the pain point of getting cjs and needing to deal with it, but I hope that we can try to sort that out (by trying for instance to convert cjs to esm using something like this for example: https://github.com/wessberg/cjstoesm). I'll leave this to James as he's been driving the chance implementation since the beginning and has already started looking at things back when, but I am happy to help or give it a shot myself if James doesn't have the time to tackle this 🙂 |
Hi all!
I've seen several comments from maintainers ([1], [2]) following up the great work of feat: fetch (suspense) cache handling, and next/cache support #419 by @james-elicx that given limitations on Cache API (e.g. per-colo cache and requires a custom domain to be configured), we'd mostly want to use alternative storage mechanisms in production (most likely KV, but perhaps other users might prefer D1/R2/DO based on specific use cases or even something else).
I understand that the ultimate intention is to let users define in their own
next.config.js
their own adaptor for caching – but there might be a pre-made snippet for KV, or an exported util they can reference.I've noted that there isn't any issue tracking that – so wanted to drop this in for that purpose, and in case maintainers want to explain more what they have in mind (or if there are any blockers they're tracking). I'm happy to take a look at contributing the changes too.
Thanks!
The text was updated successfully, but these errors were encountered: