Skip to content

Conversation

@AyronK
Copy link
Collaborator

@AyronK AyronK commented Oct 15, 2025

3.0.0 aka Next 16 support

#110

Disclaimer

✅ Version 3.0.0-next16-alpha.2 is considered compatible with Next.js 16 with no breaking changes. All non-experimental features used in your Next.js 15 projects work properly in a test environment. Please be cautious with using it though, no production environment has been adapted yet and it's still in testing phase. Please report any encountered problems as issues with [Next 16] tag.

⚠️ Experimental features from Next 15 and new cache features in Next 16 such as Components Cache are not supported! This can take several weeks to implement properly.

⚠️ cacheComponents IS NOT SUPPORTED WITH @fortedigital/nextjs-cache-handler and requires adaptation not only in the package but also projects using it as some of the old APIs are unsupported when cacheComponents is enabled.

const nextConfig: NextConfig = {
  cacheComponents: true,
}

#152 for reference

Progress on stabilization

redis-minimal example project

Are old features stable?

  • Migrating to next 16
  • Verify instrumentation
  • Verifying fetch-example
  • Verifying isr-example
  • Veryfing static-params-test
  • Veryfing tags
  • Verifying ttl
  • Verifying on demand revalidation
  • Improve example for tag on demand revalidation
  • Add example for full page on demand revalidation
  • Add example for full layout on demand revalidation
  • Add missing examples (to be decided what's missing)
  • Improve example project, add examples menu and a shared layout
  • Add examples README/docs

✅ Features without experimental flag in Next 15 are considered stable in Next 16 integration with no breaking changes.

New Next 16 stable caching features + examples

Bugs

mrjasonroy pushed a commit to mrjasonroy/nextjs-cache-handler that referenced this pull request Nov 8, 2025
This commit completes the comprehensive implementation of all examples
from the PR fortedigital#109 checklist with full Playwright test coverage.

New Examples Added:
✅ revalidate-tag - Interactive UI for testing tag revalidation
✅ revalidate-path - Interactive UI for testing path revalidation
✅ use-cache-demo - Demonstrates Next.js 16 "use cache" directive
✅ All examples have detailed explanations and code samples

Comprehensive Testing:
✅ 40+ Playwright e2e tests covering all features
✅ Homepage and navigation tests
✅ Fetch cache with tag revalidation
✅ ISR with multiple dynamic routes
✅ TTL/expiration behavior
✅ Tag and path revalidation (UI + API)
✅ "use cache" directive behavior
✅ PPR partial prerendering
✅ Static params generation
✅ API route validation and error handling
✅ Cross-page navigation
✅ Performance and caching verification

Documentation:
✅ README.md for examples with comprehensive guide
✅ EXAMPLES_TODO.md tracking implementation status
✅ Inline documentation in all example pages
✅ Code examples showing best practices
✅ Troubleshooting section

Features Demonstrated:
- Fetch caching with tags and time-based revalidation
- ISR (Incremental Static Regeneration)
- TTL/expiration with stale/expire ages
- On-demand revalidation by tag
- On-demand revalidation by path
- Next.js 16 "use cache" directive
- PPR (Partial Prerendering)
- Static params with generateStaticParams
- API routes for revalidation
- Composite cache handler (Redis + LRU)

All tests pass ✅
All examples functional ✅
Ready for production testing ✅
mrjasonroy pushed a commit to mrjasonroy/nextjs-cache-handler that referenced this pull request Nov 9, 2025
This commit adds debugging tools and testing capabilities to help diagnose
and fix known cache limitations, particularly tag persistence in development mode.

New Features:
- Cache Debug Console (UI page + API endpoint)
  - Interactive cache inspection interface
  - Environment and cache status display
  - Testing instructions and Redis CLI commands
  - Quick links to all examples for testing

- Enhanced Cache Logging
  - Debug logging wrapper for all cache operations
  - Controlled by NEXT_PRIVATE_DEBUG_CACHE environment variable
  - Traces GET/SET operations, tag revalidation, and strategy decisions

- Comprehensive Test Suite
  - Added 9 new Playwright tests for cache debug console
  - Now 50+ total tests covering all functionality
  - Tests for API endpoints, UI interactions, and documentation

Documentation:
- TESTING_LIMITATIONS.md: Strategy for testing known issues
  - Tag persistence testing workflow
  - Development vs production comparison methodology
  - Redis integration testing steps
  - Debug logging instructions

- DEVELOPMENT.md: Local development setup guide
  - Documents Turbopack module resolution issues with symlinked packages
  - Provides three workaround options
  - Includes debug logging instructions

- Updated EXAMPLES_TODO.md to reflect completed work
  - Marked all core examples as complete
  - Documented 50+ implemented tests
  - Updated documentation status

Technical Changes:
- Updated module imports to use package exports
  - Changed to @fortedigital/nextjs-cache-handler/... pattern
  - Supports proper module resolution when published

- Added cache-debug navigation link
- Enhanced cache-handler.mjs with logging wrappers
- Updated tsconfig.json (automatic Next.js dev types)

Related to PR fortedigital#109 - addresses known limitation of tags not saving in development mode
by providing debugging tools and testing infrastructure to diagnose and fix the issue.
@AyronK
Copy link
Collaborator Author

AyronK commented Nov 24, 2025

Brainstorming session with AI agent in order to prepare examples.

Next 15

Fetch API Caching Examples

  1. Fetch with force-cache (default behavior)

    • Default indefinite caching
    • Show how data persists across requests
  2. Fetch with no-store (disable caching)

    • Always fetch fresh data
    • Use cases: real-time data, user-specific content
  3. Fetch with time-based revalidation (next.revalidate)

    • Already have this, but could add variations:
    • Short intervals (seconds)
    • Long intervals (hours/days)
    • Different revalidate values per fetch
  4. Fetch with cache tags (next.tags)

    • Already have basic example, could expand:
    • Multiple tags per fetch
    • Tag hierarchies/nesting
    • Tag-based invalidation patterns
  5. Fetch with no-cache option

    • Revalidate on every request but store in cache
    • Compare with no-store

On-Demand Revalidation Examples

  1. revalidateTag - Tag-based revalidation

    • Already have basic example, could expand:
    • Revalidating multiple tags
    • Revalidating from API routes
    • Revalidating from server actions
  2. revalidatePath - Path-based revalidation

    • Revalidate specific page paths
    • Revalidate with type: 'page' | 'layout' | 'page'
    • Revalidate dynamic routes
  3. Combined revalidation (tags + paths)

    • Revalidate both tags and paths together
    • Use cases: e-commerce product updates

Route Segment Config Examples

  1. export const revalidate - Page-level revalidation

    • Time-based ISR at page level
    • Different revalidate values per route
  2. export const dynamic = 'force-static'

    • Force static generation
    • Show build-time vs runtime behavior
  3. export const dynamic = 'force-dynamic'

    • Force dynamic rendering
    • Always bypass cache
  4. export const dynamicParams = true/false

    • Already have basic example, could expand:
    • Show behavior with missing static params
    • Dynamic route generation patterns
  5. export const fetchCache = 'force-cache' | 'default' | 'only-cache' | 'force-no-store' | 'default-no-store' | 'only-no-store'

    • Control fetch caching at route level
    • Override default fetch behavior

Static Generation Examples

  1. generateStaticParams - Static params generation

    • Already have basic example, could expand:
    • Large-scale static generation
    • Conditional static params
    • Static params with revalidation
  2. Full Static Site Generation (SSG)

    • Fully static pages with no revalidation
    • Build-time data fetching

React Cache Function Examples

  1. React.cache() - Request memoization

    • Memoize function calls within a request
    • Prevent duplicate fetches in same request
    • Show deduplication in action
  2. unstable_cache - Persistent caching

    • Cache function results across requests
    • With tags and revalidation
    • Compare with fetch caching

API Route Caching Examples

  1. API Route with caching headers

    • Set Cache-Control headers
    • CDN caching strategies
    • Browser caching from API routes
  2. API Route with revalidation

    • API routes that trigger revalidation
    • Webhook handlers that revalidate cache

Next 16

1. use cache Directive

  • Cache Components with "use cache" directive
  • Show how to opt into caching at component level
  • Demonstrate automatic cache key generation
  • Compare with traditional caching approaches
  • Show cache invalidation with use cache

2. Partial Prerendering (PPR) - Stable

  • PPR with static and dynamic sections
  • PPR with Suspense boundaries
  • PPR with streaming
  • PPR performance comparison (with/without)
  • PPR with different revalidation strategies

3. Updated revalidateTag() with cacheLife Profiles

  • revalidateTag() with 'max' profile
  • revalidateTag() with 'hours' profile
  • revalidateTag() with 'days' profile
  • Custom cacheLife profiles
  • Stale-while-revalidate behavior demonstration
  • Comparison: old vs new revalidateTag() API

4. New updateTag() API

  • updateTag() in Server Actions
  • Read-your-writes semantics
  • Immediate cache invalidation after mutations
  • Form submission with instant cache update
  • User settings update with immediate reflection
  • Comparison: updateTag() vs revalidateTag()

5. Advanced Cache Life Profiles

  • Custom cache life profiles
  • Different profiles for different data types
  • Profile-based cache strategies
  • Combining multiple profiles

6. Cache Components Patterns

  • Nested cache components
  • Cache component with props
  • Cache component invalidation
  • Cache component with tags

7. PPR + Cache Integration

  • PPR with use cache components
  • PPR with unstable_cache
  • PPR with fetch caching
  • Optimizing PPR with proper caching

8. Server Actions + Caching

  • Server Action with updateTag()
  • Server Action with revalidateTag()
  • Server Action with revalidatePath()
  • Optimistic updates with cache invalidation

9. Cache Life Profile Examples

  • Short-lived cache ('hours' profile)
  • Long-lived cache ('days' profile)
  • Maximum cache ('max' profile)
  • Custom time-based profiles

10. Real-World Use Cases

  • E-commerce product page with PPR + updateTag()
  • Blog with PPR + cache components
  • Dashboard with multiple cache strategies
  • User profile with read-your-writes semantics

11. Performance Comparisons

  • PPR vs traditional SSR
  • use cache vs unstable_cache vs fetch
  • Different cacheLife profiles performance
  • Cache hit rate comparisons

12. Error Handling with Caching

  • Cache fallback strategies
  • Error boundaries with cached data
  • Stale-while-revalidate error handling

AyronK and others added 4 commits November 24, 2025 11:42
* Extra examples

* Layout changes

* Added unstable cache example
…ler) (#162)

* Added revalidate profile example

* Added updateTag example
* Added compatibility matrix

* Readme improvements

* F

* F
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.

2 participants