Skip to content

feat: add an experimental KV based tag cache#906

Merged
vicb merged 6 commits intomainfrom
vicb/tag-kv
Sep 25, 2025
Merged

feat: add an experimental KV based tag cache#906
vicb merged 6 commits intomainfrom
vicb/tag-kv

Conversation

@vicb
Copy link
Copy Markdown
Contributor

@vicb vicb commented Sep 24, 2025

No description provided.

@vicb vicb requested a review from conico974 September 24, 2025 11:27
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Sep 24, 2025

🦋 Changeset detected

Latest commit: b27784b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@opennextjs/cloudflare Minor

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Sep 24, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@opennextjs/cloudflare@906

commit: b27784b

Comment thread packages/cloudflare/src/api/overrides/tag-cache/kv-next-tag-cache.ts Outdated
Copy link
Copy Markdown
Collaborator

@conico974 conico974 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some small little change needed and a few thing maybe to add as comment

Comment thread examples/overrides/kv-tag-next/package.json Outdated
Comment thread packages/cloudflare/src/api/overrides/tag-cache/kv-next-tag-cache.ts Outdated
Comment thread packages/cloudflare/src/api/overrides/tag-cache/kv-next-tag-cache.ts Outdated
await kv.put(this.getCacheKey(tag), timeMs);
})
);
await purgeCacheByTags(tags);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already done in aws, we should not do it again here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I guess it should be removed from D1 and DO too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how/where this is done in aws though?
Can you point to the code?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

@vicb vicb Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before checking the length, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see what you mean, we should implement a new method in the CDN invalidation.

So I guess this code is good to merge now (I'll add a TODO here and for D1 & DO).
(A follow-up I had was to only call purgeCacheByTags when there is a CDN invalidator so that we do not log errors when not).

I could create an issue in aws to add the method and reference it in this repo.

Do that sound good?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah perfect

vicb and others added 3 commits September 24, 2025 19:05
…che.ts

Co-authored-by: conico974 <nicodorseuil@yahoo.fr>
Co-authored-by: conico974 <nicodorseuil@yahoo.fr>
@vicb
Copy link
Copy Markdown
Contributor Author

vicb commented Sep 25, 2025

Thanks for the review and feedback Nico!

@vicb vicb merged commit dcc864d into main Sep 25, 2025
7 checks passed
@vicb vicb deleted the vicb/tag-kv branch September 25, 2025 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants