Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 19 additions & 26 deletions pages/cloudflare/caching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,21 @@ In your project's OpenNext config, enable the KV cache and set up a queue.

The memory queue will send revalidation requests to a page when needed, and offers support for de-duplicating requests on a per-isolate basis. There might still be duplicate requests under high traffic or across regions.

<Callout type="warning">
The memory queue provided by `@opennextjs/cloudflare` is not fully suitable for production deployments, you
can use it at your own risk!
</Callout>

```ts
// open-next.config.ts
import incrementalCache from "@opennextjs/cloudflare/kv-cache";
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
import kvIncrementalCache from "@opennextjs/cloudflare/kv-cache";
import memoryQueue from "@opennextjs/cloudflare/memory-queue";

const config: OpenNextConfig = {
default: {
override: {
// ...
incrementalCache: () => incrementalCache,
queue: () => memoryQueue,
},
},
// ...
};

export default config;
export default defineCloudflareConfig({
incrementalCache: kvIncrementalCache,
queue: memoryQueue,
});
```

<Callout>
Expand Down Expand Up @@ -126,21 +124,16 @@ In your project's OpenNext config, enable the KV cache and set up a queue. The q

```ts
// open-next.config.ts
import tagCache from "@opennextjs/cloudflare/d1-tag-cache";
import incrementalCache from "@opennextjs/cloudflare/kv-cache";
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
import kvIncrementalCache from "@opennextjs/cloudflare/kv-cache";
import d1TagCache from "@opennextjs/cloudflare/d1-tag-cache";
import memoryQueue from "@opennextjs/cloudflare/memory-queue";

const config: OpenNextConfig = {
default: {
override: {
// ...
incrementalCache: () => incrementalCache,
queue: () => memoryQueue,
tagCache: () => tagCache,
},
},
// ...
};
export default defineCloudflareConfig({
incrementalCache: kvIncrementalCache,
tagCache: d1TagCache,
queue: memoryQueue,
});
```

##### 4. Initialise the cache during deployments
Expand Down
30 changes: 5 additions & 25 deletions pages/cloudflare/get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,32 +87,12 @@ You can create one yourself in the root directory of your Next.js app with the n
Add a [`open-next.config.ts`](https://opennext.js.org/aws/config) file to the root directory of your Next.js app:

```ts
import type { OpenNextConfig } from "@opennextjs/aws/types/open-next.js";
import cache from "@opennextjs/cloudflare/kv-cache";

const config: OpenNextConfig = {
default: {
override: {
wrapper: "cloudflare-node",
converter: "edge",
// set `incrementalCache` to "dummy" to disable KV cache
incrementalCache: async () => cache,
tagCache: "dummy",
queue: "dummy",
},
},

middleware: {
external: true,
override: {
wrapper: "cloudflare-edge",
converter: "edge",
proxyExternalRequest: "fetch",
},
},
};
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
import kvIncrementalCache from "@opennextjs/cloudflare/kv-cache";

export default config;
export default defineCloudflareConfig({
incrementalCache: kvIncrementalCache,
});
```

<Callout>
Expand Down