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 setupREDIS_PREFIX=vactoryREDIS_HOST=127.0.0.1REDIS_PORT=6379REDIS_USERNAME=defaultREDIS_PASSWORD=YOUR_REDIS_PASSWORDCACHE_SECRET=YOUR_CACHE_SECRET
# Router && Node Expire timeREDIS_ROUTER_EXPIRE=300REDIS_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:
- Restart your Next.js development server
- Ensure your Redis server is running and accessible
- Verify the connection by checking your application logs
- 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.