🎉 1.5.0 is out! It features the new experimental-redis-cluster Handler for Redis Cluster support!
Introduction

Welcome to @neshca/cache-handler, a specialized ISR/Data cache API crafted for Next.js applications. This library simplifies configuring shared cache strategies in distributed environments, such as multiple, independent application instances. It offers a flexible and easy-to-integrate solution for custom cache strategies, especially for Redis.


Next.js applications are often deployed in a self-hosted distributed environment, where multiple instances of the same application are running simultaneously. In such cases, the default Next.js cache is not shared between instances, causing the data to diverge between independent instances because load balancers route requests to a different instance every time. Another significant issue with the default cache setup is on-demand revalidation; it requires manual revalidation across all application replicas.

Features

  • Shared Cache for Distributed Environments: Perfect for self-hosted deployments with multiple application instances.
  • Easy Customization: Provides a straightforward API with pre-configured Handlers.
  • On-Demand Revalidation: Simplifies revalidation across all application replicas.
  • TTL Management: Automatic cache cleanup to keep storage space efficient.
  • Support for Next.js Routers: Full support and one setup for the Pages and the App Router.
  • neshCache Function: Utilize the neshCache function to replace unstable_cache for more control over caching.

Getting Started

Enhance your application's caching with our Installation and First Steps Guide. This guide covers installation, basic configuration, and practical examples for quick integration.

Examples

Explore the versatility of @neshca/cache-handler in our Examples Section with real-world scenarios. Learn how to build a custom Handler by following this guide.