Skip to content

Commit c200d7a

Browse files
committed
feat(core): run the cache in a dedicated handler function
Add a standalone cache handler function that owns the incremental cache, the tag cache and CDN invalidation, and a `cache` override that other functions use to reach it. - `adapters/cache-adapter.ts` exposes `GET/PUT/DELETE /cache/*` and `POST /cache/revalidate-tags` through `createGenericHandler`. - `build/createCacheBundle.ts` bundles it to `.open-next/cache-function`, wired into `buildAdapter` behind the new `skipCache` option and reported as `cacheFunction` in the OpenNext output. - New top level `cacheHandler` config option carries the incremental cache, tag cache and cdn invalidation overrides for that function. - New `cache` override with `fetch`, `local` and `dummy` implementations, and a shared wire format in `utils/cache-get.ts` that splits the entry metadata into headers and the payload into the body. Nothing is removed here: the existing in-process `incrementalCache` and `tagCache` overrides keep working unchanged.
1 parent cd8f83e commit c200d7a

21 files changed

Lines changed: 1811 additions & 8 deletions
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
"@opennextjs/core": minor
3+
---
4+
5+
Add a dedicated cache handler function
6+
7+
The incremental cache, the tag cache and CDN invalidation can now run in their own function, bundled
8+
to `.open-next/cache-function` and reachable over the new `cache` override.
9+
10+
The overrides for that function are configured through a new top level `cacheHandler` option:
11+
12+
```ts
13+
export default {
14+
default: {
15+
override: {
16+
cache: "local",
17+
},
18+
},
19+
cacheHandler: {
20+
incrementalCache: "s3",
21+
tagCache: "dynamodb",
22+
},
23+
} satisfies OpenNextConfig;
24+
```
25+
26+
Three `cache` implementations ship with core: `fetch` (HTTP), `local` (in-process, imports the cache
27+
bundle) and `dummy`. Adapters that do not want the bundle can opt out with `skipCache` in
28+
`buildAdapter`.
29+
30+
This is additive: the existing `default.override.incrementalCache` and `default.override.tagCache`
31+
keep working unchanged.

0 commit comments

Comments
 (0)