Caching Setup


Caching is essential for optimal performance in your Vactory application. By implementing Redis caching, you can significantly reduce response times and server load by storing frequently accessed data in memory.

Redis Configuration

Add the following environment variables to your Next.js app .env file and ensure that you provide the appropriate values for your Redis setup:

.env

# Redis setup
REDIS_PREFIX=vactory
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_USERNAME=default
REDIS_PASSWORD=YOUR_REDIS_PASSWORD
CACHE_SECRET=YOUR_CACHE_SECRET
# Router && Node Expire time
REDIS_ROUTER_EXPIRE=300
REDIS_NODE_EXPIRE=60

Configuration Parameters

Redis Connection Settings

  • REDIS_PREFIX: Namespace prefix for all cache keys to avoid conflicts
  • REDIS_HOST: Redis server hostname or IP address
  • REDIS_PORT: Redis server port (default: 6379)
  • REDIS_USERNAME: Redis authentication username
  • REDIS_PASSWORD: Redis authentication password

Cache Security

  • CACHE_SECRET: Secret key used for cache invalidation API endpoint security

Cache Expiration Settings

  • REDIS_ROUTER_EXPIRE: Router cache expiration time in seconds (default: 300 = 5 minutes)
  • REDIS_NODE_EXPIRE: Node data cache expiration time in seconds (default: 60 = 1 minute)

Next Steps

After configuring these environment variables:

  1. Restart your Next.js development server
  2. Ensure your Redis server is running and accessible
  3. Verify the connection by checking your application logs
  4. Configure cache revalidation rules as needed

Your Vactory application will now use Redis for caching router information, node data, menus, and translations to improve performance.