|
1 | | -This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). |
| 1 | +# Next.js 16 Cache Handler - Examples |
| 2 | + |
| 3 | +This example application demonstrates comprehensive caching strategies using `@fortedigital/nextjs-cache-handler` with Next.js 16. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +This example showcases: |
| 8 | + |
| 9 | +- ✅ **Fetch Caching** - HTTP fetch with tags and time-based revalidation |
| 10 | +- ✅ **ISR** (Incremental Static Regeneration) - Dynamic routes with caching |
| 11 | +- ✅ **TTL/Expiration** - Time-to-live and cache expiration behavior |
| 12 | +- ✅ **Tag Revalidation** - On-demand revalidation by cache tags |
| 13 | +- ✅ **Path Revalidation** - On-demand revalidation by route paths |
| 14 | +- ✅ **"use cache" Directive** - Next.js 16's component-level caching |
| 15 | +- ✅ **PPR** (Partial Prerendering) - Mixed static/dynamic content |
| 16 | +- ✅ **Static Params** - `generateStaticParams` with caching |
| 17 | +- ✅ **Comprehensive Tests** - Playwright e2e tests for all features |
2 | 18 |
|
3 | 19 | ## Getting Started |
4 | 20 |
|
5 | | -First, run the development server: |
| 21 | +### Prerequisites |
| 22 | + |
| 23 | +- Node.js 22+ |
| 24 | +- Redis server (optional, falls back to LRU) |
| 25 | + |
| 26 | +### Installation |
| 27 | + |
| 28 | +\`\`\`bash |
| 29 | +npm install |
| 30 | +\`\`\` |
| 31 | + |
| 32 | +### Running the Development Server |
6 | 33 |
|
7 | | -```bash |
8 | | -npm i |
| 34 | +\`\`\`bash |
9 | 35 | npm run dev |
10 | | -``` |
| 36 | +\`\`\` |
11 | 37 |
|
12 | | -Or run build and run production server: |
| 38 | +Open [http://localhost:3000](http://localhost:3000) to see the examples. |
13 | 39 |
|
14 | | -```bash |
15 | | -npm i |
16 | | -npm run build |
17 | | -npm run start |
18 | | -``` |
| 40 | +### Running Tests |
19 | 41 |
|
20 | | -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. |
| 42 | +\`\`\`bash |
| 43 | +# Run all e2e tests |
| 44 | +npm run test:e2e |
21 | 45 |
|
22 | | -Modify `.env` file if you need to. |
| 46 | +# Run tests in UI mode |
| 47 | +npm run test:e2e:ui |
23 | 48 |
|
24 | | -## Examples |
| 49 | +# Run tests in headed mode (see browser) |
| 50 | +npm run test:e2e:headed |
| 51 | +\`\`\` |
25 | 52 |
|
26 | | -- http://localhost:3000 |
27 | | -- http://localhost:3000/fetch-example |
28 | | -- http://localhost:3000/static-params-test/cache |
| 53 | +## Learn More |
29 | 54 |
|
30 | | -## Clear fetch example cache |
| 55 | +- [Next.js 16 Documentation](https://nextjs.org/docs) |
| 56 | +- [@fortedigital/nextjs-cache-handler](https://github.com/fortedigital/nextjs-cache-handler) |
| 57 | +- [Playwright Testing](https://playwright.dev/) |
31 | 58 |
|
32 | | -- http://localhost:3000/api/cache |
| 59 | +See EXAMPLES_TODO.md for implementation checklist. |
0 commit comments