The Redis cache handler stores Next.js cache values as uncompressed JSON, wasting 2.5-10x more memory than necessary. Serialization is hardcoded in redis-strings.ts with no way to add compression, encryption, or custom formats.
My ideas is to:
Implement a pluggable serializer system with:
- Strategy pattern for serialization/deserialization
defaultSerializer - no compression (backward compatible)
gzipSerializer - 60-85% size reduction
- Extensible
CacheSerializer interface for custom implementations
Impact
Reduces Redis memory usage and infrastructure costs while enabling customization for compression algorithms, encryption, or specialized formats.
I am happy to look at implementing.
(EDIT: I stupidly opened the wrong issue for this repo as I mixed up tabs 😬 )
The Redis cache handler stores Next.js cache values as uncompressed JSON, wasting 2.5-10x more memory than necessary. Serialization is hardcoded in redis-strings.ts with no way to add compression, encryption, or custom formats.
My ideas is to:
Implement a pluggable serializer system with:
defaultSerializer- no compression (backward compatible)gzipSerializer- 60-85% size reductionCacheSerializerinterface for custom implementationsImpact
Reduces Redis memory usage and infrastructure costs while enabling customization for compression algorithms, encryption, or specialized formats.
I am happy to look at implementing.
(EDIT: I stupidly opened the wrong issue for this repo as I mixed up tabs 😬 )