-
Notifications
You must be signed in to change notification settings - Fork 45
Set "cache-tag" on the regional cache entries #551
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
Conversation
🦋 Changeset detectedLatest commit: 54b0ed8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, we'd want the purge to be automatic.
This means we'd have another override for the tag cache that would work in the same way as this one (by wrapping the tag cache used) and that would call cloudflare api to purge cache entry automatically on writeTags
.
We'd also want to provide this https://opennext.js.org/aws/config/overrides/automatic_cdn_invalidation so that it would work for res.revalidate
from page router as well.
packages/cloudflare/src/api/overrides/incremental-cache/regional-cache.ts
Outdated
Show resolved
Hide resolved
packages/cloudflare/src/api/overrides/incremental-cache/regional-cache.ts
Show resolved
Hide resolved
It makes sense, I guess it can be done in another PR? @conico974 I've made the other suggested changes, let me know if they match what you had in mind. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just made 2 small comments but other than that, it looks good
It makes sense, I guess it can be done in another PR?
Yeah we can do it in another PR later.
packages/cloudflare/src/api/overrides/incremental-cache/regional-cache.ts
Outdated
Show resolved
Hide resolved
packages/cloudflare/src/api/overrides/incremental-cache/regional-cache.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks
packages/cloudflare/src/api/overrides/incremental-cache/regional-cache.ts
Outdated
Show resolved
Hide resolved
packages/cloudflare/src/api/overrides/incremental-cache/regional-cache.ts
Show resolved
Hide resolved
packages/cloudflare/src/api/overrides/incremental-cache/regional-cache.ts
Outdated
Show resolved
Hide resolved
packages/cloudflare/src/api/overrides/incremental-cache/regional-cache.ts
Outdated
Show resolved
Hide resolved
Thanks @SamyPesse for the PR, could you please prepare a PR for the docs at https://github.com/opennextjs/docs @SamyPesse or @conico974 could you please create a feature request for the follow up. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's merge once the comments are resolved.
Thanks @vicb and @conico974, I'll merge it and look at making a PR on the docs (It'd be great to have it hosted on GitBook :D ) EDIT: I can't merge, so one of you will have to do it if changes are good for you |
Actually, for the documentation, it could be better to wait for #555 before writing it as by itself this PR doesn't make it a standalone solution for most people using Opennext. |
Co-authored-by: Victor Berchet <victor@suumit.com>
0dde4b2
to
feba75e
Compare
I added one last commit + rebase, let me know if this looks good |
Perfect! thanks @vicb |
This PR aims at improving the use of the regional cache by making sure that entries on it can be purged by cache-tag on Cloudflare.
In our application (https://github.com/GitbookIO/gitbook), we purge the cache both using
revalidateTag
but also using the Cloudflare API (https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-tags/).I think this header has no negative impact on any other OpenNext users while unblocking us but also potentially unblocking someone who is using the long-lived cache and needs to quickly purge it (they could do it from the CF dashboard).