Skip to content

Commit 53ebf96

Browse files
conico974Nicolas Dorseuil
and
Nicolas Dorseuil
authored
[cloudflare] docs for #496 (#156)
Co-authored-by: Nicolas Dorseuil <nicolas@gitbook.io>
1 parent dbf0c77 commit 53ebf96

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pages/cloudflare/caching.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,30 @@ You can customize the behaviors of the queue with environment variables:
484484

485485
</Callout>
486486

487+
In certain situations, you may encounter the limits of what the Durable Object queue can manage for a single page or route. In such cases, you can utilize the queueCache to minimize the number of stale requests sent to the queue. This is achieved by adding and verifying a cache entry via the Cache API before dispatching a request to the queue. If a cache entry already exists, the request will not be sent to the queue, as it will be considered already in process.
488+
489+
```ts
490+
// open-next.config.ts
491+
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
492+
// ...
493+
import r2IncrementalCache from "@opennextjs/cloudflare/overrides/incremental-cache/r2-incremental-cache";
494+
import doQueue from "@opennextjs/cloudflare/overrides/queue/do-queue";
495+
import queueCache from "@opennextjs/cloudflare/overrides/queue/queue-cache";
496+
497+
export default defineCloudflareConfig({
498+
// ...
499+
incrementalCache: r2IncrementalCache,
500+
queue: queueCache(doQueue, {
501+
regionalCacheTtlSec: 5, // The TTL for the regional cache, defaults to 5 seconds
502+
503+
// Whether to wait for the queue to acknowledge the request before returning
504+
// When set to false, the cache will be populated asap and the queue will be called after.
505+
// When set to true, the cache will be populated only after the queue ack is received.
506+
waitForQueueAck: true,
507+
}),
508+
});
509+
```
510+
487511
#### Tag Cache for On-Demand Revalidation
488512

489513
The tag revalidation mechanism can use either a [Cloudflare D1](https://developers.cloudflare.com/d1/) database or [Durable Objects](https://developers.cloudflare.com/durable-objects/) with `SqliteStorage` as its backing store for information about tags, paths, and revalidation times.

0 commit comments

Comments
 (0)