-
Notifications
You must be signed in to change notification settings - Fork 73
Add option for regional cache to skip tagCache on cache hits #850
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
Merged
dario-piotrowicz
merged 9 commits into
main
from
dario/regional-cache-shouldBypassTagCache
Aug 18, 2025
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4e4fe42
fix: make regional cache hits bypass the tagCache
dario-piotrowicz df0f1dd
add `bypassTagCacheOnCacheHit` option
dario-piotrowicz aa204fd
fix issue of calling `getCloudflareContext` too early
dario-piotrowicz bfd06df
Update packages/cloudflare/src/api/overrides/incremental-cache/region…
dario-piotrowicz 49cd870
update incorrect check
dario-piotrowicz c0f8405
also pass `shouldBypassTagCache` flag on r2 hits
dario-piotrowicz fcb325e
Fix typo
dario-piotrowicz 23d262d
remove incorrect shouldBypassTagCache
dario-piotrowicz 6082569
properly await json
dario-piotrowicz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
"@opennextjs/cloudflare": minor | ||
--- | ||
|
||
Add option for regional cache to skip tagCache on cache hits | ||
|
||
When the tag regional cache finds a value in the incremental cache, checking such value in the tagCache can be skipped, this helps reducing response times at the tradeoff that the user needs to either use the automatic cache purging or manually purge the cache when appropriate. For this the `bypassTagCacheOnCacheHit` option is being added to the `RegionalCache` class. | ||
|
||
Example: | ||
|
||
```js | ||
import { defineCloudflareConfig } from "@opennextjs/cloudflare"; | ||
import d1NextTagCache from "@opennextjs/cloudflare/overrides/tag-cache/d1-next-tag-cache"; | ||
import memoryQueue from "@opennextjs/cloudflare/overrides/queue/memory-queue"; | ||
import r2IncrementalCache from "@opennextjs/cloudflare/overrides/incremental-cache/r2-incremental-cache"; | ||
import { withRegionalCache } from "@opennextjs/cloudflare/overrides/incremental-cache/regional-cache"; | ||
|
||
export default defineCloudflareConfig({ | ||
incrementalCache: withRegionalCache(r2IncrementalCache, { | ||
mode: "long-lived", | ||
bypassTagCacheOnCacheHit: true, | ||
}), | ||
tagCache: d1NextTagCache, | ||
queue: memoryQueue, | ||
}); | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.