All notable changes to this project will be documented in this file.
- Fixed TypeScript compilation errors with Vercel cache API
- Removed invalid generic type parameter from
cache.get<CacheEntry>()call - Added proper type assertion for cache.get() return value
- Resolved type mismatch issues in cache entry handling functions
- Removed invalid generic type parameter from
- Support for caching POST and PUT requests
- Enables GraphQL query caching
- Each unique request body generates a different cache key
- Particularly useful for GraphQL endpoints where different queries need separate cache entries
- GraphQL examples in documentation
- Updated cache logic to include POST and PUT methods alongside GET
- Documentation now highlights GraphQL support as a key feature
- SWR (Stale-While-Revalidate) caching strategy
- Returns stale data immediately while refreshing in the background
- Uses Vercel's
waitUntil()to extend request lifetime for background refresh - Separates
revalidatetime fromexpirestime for optimal performance
- New
next.expiresoption to set absolute cache expiry time- Allows serving stale data beyond revalidation time
- Defaults to 24 hours or 10x revalidate time, whichever is larger
- Better cache TTL management based on expiry times
- Cache entries now store both
revalidateAfterandexpiresAttimestamps - Improved cache validation logic to support SWR behavior
- Documentation clarified that tag-based revalidation is not automatic
- BREAKING: Complete rewrite of cache key generation to exactly match Next.js behavior
- Now uses "v3" version prefix for compatibility
- Generates SHA-256 hash of request components
- Automatically removes 'traceparent' and 'tracestate' headers to prevent cache fragmentation
- Includes all request properties in specific order (URL, method, headers, mode, redirect, credentials, referrer, referrerPolicy, integrity, cache, body)
- Supports custom cache key prefixes via
next.fetchCacheKeyPrefix
- Improved body handling for different types:
- Uint8Array: decode to string, preserve original
- ReadableStream: consume stream, collect chunks, reconstruct as Uint8Array
- FormData/URLSearchParams: serialize key-value pairs
- Blob: convert to text and preserve as new Blob with same type
- String: use directly
- Support for
next.fetchCacheKeyPrefixoption for multi-tenant scenarios - Environment-specific SHA-256 hashing (crypto.subtle.digest for Edge, crypto.createHash for Node)
- Initial release
- Drop-in replacement for fetch in Next.js middleware
- Uses Vercel Runtime Cache for persistence
- Supports Next.js fetch options (cache, next.revalidate, next.tags)
- Automatic cache key generation
- Graceful fallback to regular fetch if cache fails