Skip to content

New Cache implementation#31

Draft
conico974 wants to merge 11 commits into
mainfrom
conico/cache-v2
Draft

New Cache implementation#31
conico974 wants to merge 11 commits into
mainfrom
conico/cache-v2

Conversation

@conico974
Copy link
Copy Markdown
Contributor

@conico974 conico974 commented May 5, 2026

Move the cache into a separate function/service that can be deployed separately.
This separate cache service will become responsible for handling anything cache related (i.e. checking the tag cache and incremental cache)
This cache service can also be called locally as if it was a function for cases where we don't want to deploy the cache as a separate service.

TODO:

  • Do the cloudflare implementation
  • Rebase on top of the SWR PR (some part have been ported here, but it's a mess and make the PR too big)

conico974 and others added 11 commits May 1, 2026 10:20
Expose RESTful routes (GET/PUT/DELETE /cache/*, POST /cache/revalidate-tags)
for remote cache operations, backed by the pluggable IncrementalCache,
TagCache, and CDNInvalidationHandler interfaces. Guarded by
disableIncrementalCache config option.
The cache adapter GET response now encodes metadata into x-opennext-cache-*
headers and only the relevant payload in the response body. Adds
parseCacheGetResponse helper to reconstruct the cache value on the client side.

- Not-found entries return 404 with x-opennext-cache-found: false header
- Composable, fetch, and route entries return body as text/plain
- Page, app, and redirect entries return structured JSON body
- Individual data/meta headers are split into x-opennext-cache-header-{name}
…deOptions, delegate to cache override

Move tag revalidation logic (hasBeenRevalidated, writeTags, CDN invalidation)
from the Next.js Cache class into the cache handler (cache-adapter.ts).
The cache override now handles all tag operations transparently in get/set/revalidateTags.
Update cache.ts, composable-cache.ts, and cacheInterceptor.ts to use globalThis.cache.
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
… and local cache methods

Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant