All Insights
Performance & SaaS2026-10-04 · 4 min read

Sub-Second Dashboards in Next.js + MySQL SaaS Using Pragmatic Redis Caching

A simple read-through caching and tenant key-invalidation strategy that keeps multi-tenant SaaS dashboards fast under load.

1. Cache Tenant Aggregations, Not Everything

In a multi-tenant SaaS like a gym or operations management platform, overview counters (active members, expiring subscriptions, monthly totals) are read dozens of times per minute by staff.

Caching these aggregated DTOs in Redis with short TTLs + event-driven invalidation eliminates repetitive `COUNT(*)` and `SUM()` scans on MySQL.

2. Namespaced Keys & Explicit Invalidation

Prefix every Redis key with `tenant:{id}:resource` so updates cleanly purge only the affected tenant's cached summary.

const cacheKey = `tenant:${tenantId}:dashboard:summary`;
const cached = await redis.get(cacheKey);
if (cached) return JSON.parse(cached);

const summary = await computeTenantMetricsFromMySQL(tenantId);
await redis.set(cacheKey, JSON.stringify(summary), "EX", 120);
return summary;

Need help building a system like this?

Book a Call