Skip to content

Commit 54cf1ba

Browse files
committed
Added compatibility matrix
1 parent aab6a85 commit 54cf1ba

File tree

2 files changed

+49
-12
lines changed

2 files changed

+49
-12
lines changed

README.md

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,56 @@ The documentation at [@neshca/cache-handler - caching-tools.github.io/next-share
2020

2121
If upgrading from Next 14 or earlier, **flush your Redis cache** before running new version of the application locally and on your hosted environments. **Cache formats between Next 14 and 15 are incompatible**.
2222

23-
## Next 15 Support
23+
## Next.js Compatibility
2424

2525
The original `@neshca/cache-handler` package does not support Next.js 15.
2626

2727
Prior to 2.0.0, this package provided wrappers and enhancements to allow using `@neshca/cache-handler` with Next.js 15.
2828
From version 2.0.0 onward, `@fortedigital/nextjs-cache-handler` is a standalone solution with no dependency on `@neshca/cache-handler` and is fully compatible with Next.js 15 and [redis 5](https://www.npmjs.com/package/redis).
2929

30+
**Version Requirements:**
31+
32+
- **Next.js 15**: Version 2.0.0+ (version 3.0.0+ recommended for latest improvements and maintenance development)
33+
- **Next.js 16**: Version 3.0.0+ required
34+
3035
We aim to keep up with new Next.js releases and will introduce major changes with appropriate version bumps.
3136

37+
### Feature Compatibility Matrix
38+
39+
| Feature | Next.js 15 | Next.js 16 | Notes |
40+
| ---------------------------------------------------- | ---------- | ---------- | ---------------------------------------------------- |
41+
| **Fetch API Caching** |
42+
| `fetch` with default cache (`force-cache`) ||| Default behavior, caches indefinitely |
43+
| `fetch` with `no-store` ||| Never caches, always fresh |
44+
| `fetch` with `no-cache` ||| Validates cache on each request |
45+
| `fetch` with `next.revalidate` ||| Time-based revalidation |
46+
| `fetch` with `next.tags` ||| Tag-based cache invalidation |
47+
| **Cache Invalidation** |
48+
| `revalidateTag(tag)` || N/A | Breaking change in Next.js 16 |
49+
| `revalidateTag(tag, cacheLife)` | N/A || New required API in Next.js 16 |
50+
| `updateTag(tag)` | N/A || New API for immediate invalidation in Server Actions |
51+
| `revalidatePath(path)` ||| Path-based revalidation |
52+
| `revalidatePath(path, type)` ||| Type-specific path revalidation |
53+
| **Function Caching** |
54+
| `unstable_cache()` ||| Cache any function with tags and revalidation |
55+
| **Static Generation** |
56+
| `generateStaticParams()` ||| Static params generation |
57+
| ISR (Incremental Static Regeneration) ||| On-demand regeneration |
58+
| Route segment config (`revalidate`, `dynamic`, etc.) ||| All segment config options |
59+
| **Next.js 16 New Features** |
60+
| `cacheHandlers` config (for `'use cache'`) ||| Not yet supported - Planned for Next 16 |
61+
| `'use cache'` directive ||| Not yet supported - Planned for Next 16 |
62+
| `'use cache: remote'` directive ||| Not yet supported - Planned for Next 16 |
63+
| `'use cache: private'` directive ||| Not yet supported - Planned for Next 16 |
64+
| `cacheComponents` ||| Not yet supported - Planned for Next 16 |
65+
66+
**Notes:**
67+
68+
- `revalidateTag()` in Next.js 16 requires a `cacheLife` parameter (`'max'`, `'hours'`, or `'days'`). This is a breaking change from Next.js 15.
69+
- `cacheLife` profiles are primarily designed for Vercel's infrastructure. Custom cache handlers may not fully differentiate between different `cacheLife` profiles.
70+
- `updateTag()` is only available in Server Actions, not Route Handlers.
71+
- The new `cacheHandlers` API and `'use cache'` directives are not yet supported by this package.
72+
3273
### Swapping from `@neshca/cache-handler`
3374

3475
If you already use `@neshca/cache-handler` the setup is very streamlined and you just need to replace package references. If you're starting fresh please check [the example project](./examples/redis-minimal).
@@ -479,7 +520,6 @@ For context or historical documentation, you may still reference the [original p
479520
480521
`neshClassicCache` allows you to cache the results of expensive operations, like database queries, and reuse them across multiple requests. Unlike the [`neshCache`](/functions/nesh-cache) or [`unstable_cache` ↗](https://nextjs.org/docs/app/api-reference/functions/unstable_cache) function, `neshClassicCache` must be used in a Next.js Pages Router allowing users to cache data in the `getServerSideProps` and API routes.
481522
482-
483523
> [!NOTE]
484524
>
485525
> Cache entries created with `neshClassicCache` can be revalidated only by the [`revalidateTag` ↗](https://nextjs.org/docs/app/api-reference/functions/revalidateTag) method.
@@ -513,11 +553,11 @@ This is an object that controls how the cache behaves. It can contain the follow
513553
### Example
514554
515555
```jsx filename="src/pages/api/api-example.js" copy
516-
import { neshClassicCache } from '@fortedigital/nextjs-cache-handler/functions';
517-
import axios from 'axios';
556+
import { neshClassicCache } from "@fortedigital/nextjs-cache-handler/functions";
557+
import axios from "axios";
518558

519559
export const config = {
520-
runtime: 'nodejs',
560+
runtime: "nodejs",
521561
};
522562

523563
async function getViaAxios(url) {
@@ -531,22 +571,22 @@ async function getViaAxios(url) {
531571
const cachedAxios = neshClassicCache(getViaAxios);
532572

533573
export default async function handler(request, response) {
534-
if (request.method !== 'GET') {
574+
if (request.method !== "GET") {
535575
return response.status(405).send(null);
536576
}
537577

538578
const revalidate = 5;
539579

540-
const url = new URL('https://api.example.com/data.json');
580+
const url = new URL("https://api.example.com/data.json");
541581

542582
// Add tags to be able to revalidate the cache
543583
const data = await cachedAxios(
544584
{ revalidate, tags: [url.pathname], responseContext: response },
545-
url,
585+
url
546586
);
547587

548588
if (!data) {
549-
response.status(404).send('Not found');
589+
response.status(404).send("Not found");
550590

551591
return;
552592
}

examples/redis-minimal/next.config.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ import type { NextConfig } from "next";
33
const nextConfig: NextConfig = {
44
cacheHandler: require.resolve("./cache-handler.mjs"),
55
cacheMaxMemorySize: 0, // disable default in-memory caching
6-
experimental: {
7-
//ppr: "incremental",
8-
},
96
};
107

118
export default nextConfig;

0 commit comments

Comments
 (0)