You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//import { withFilter, softTagFilter } from "@opennextjs/cloudflare/overrides/tag-cache/tag-cache-filter";
97
98
98
99
exportdefaultdefineCloudflareConfig({
99
100
incrementalCache: r2IncrementalCache,
100
101
queue: doQueue,
101
102
// This is only required if you use On-demand revalidation
102
103
tagCache: d1NextTagCache,
104
+
//If you don't use `revalidatePath`, you can also filter internal soft tags using the `softTagFilter`
105
+
// tagCache: withFilter({
106
+
// tagCache: d1NextTagCache,
107
+
// filterFn: softTagFilter,
108
+
// }),
103
109
});
104
110
```
105
111
@@ -449,7 +455,7 @@ Which one to choose should be based on two key factors:
449
455
450
456
If either of these factors is significant, opting for a sharded database is recommended. Additionally, incorporating a regional cache can further enhance performance.
@@ -588,5 +594,34 @@ doShardedTagCache takes the following options:
588
594
-`numberOfHardReplicas`: Number of replicas for the hard tag shards
589
595
-`maxWriteRetries`: The number of retries to perform when writing tags
590
596
597
+
</Tabs.Tab>
598
+
<Tabs.Tab>
599
+
<Callout>
600
+
The `withFilter` option is a specialized configuration that enhances your `tagCache` by layering an additional filter. It requires another tag cache to be passed in as the tagCache (e.g., `d1NextTagCache`, `doShardedTagCache` or your own).
601
+
</Callout>
602
+
This enhanced tag cache selectively filters which tags trigger revalidations, allowing you to focus on a specific subset and reduce unnecessary load on the underlying tag cache. For convenience, we provide the ready-to-use `softTagFilter` that automatically filters out tags used by the `revalidatePath` function making it a no-op.
603
+
604
+
Its primary purpose is to filter out soft tags (i.e., those used by `revalidatePath`) from the tag cache, which are not relevant for your application. It could also be used to filter out hard tags (i.e., those you define in your app) if one of your dependencies uses them.
You can also create your own custom filter function. This function must return a boolean value indicating whether a tag should be included. It will be invoked with a single tag (as a string) as its argument. Please note that "soft tags" (i.e., those used by revalidatePath) always start with the prefix `_N_T`.
0 commit comments