← Back to Docs
Performance

Caching Strategies

Reduce latency and server load with Meridian's multi-tier caching architecture.

Edge Cache (CDN)

Static assets and immutable responses are cached at Vercel's global edge network. Set Cache-Control: public, max-age=31536000, immutable for fingerprints like /api/public/*.

In-Memory LRU

Hot license validations and session lookups hit an in-process LRU with a 60-second TTL. Eviction is size-bounded at 10,000 entries. Misses fall through to Upstash KV.

Upstash KV (Redis)

Durable cache for user entitlements, feature flags, and rate-limit counters. All writes use SETEX with appropriate TTLs. Reads are pipelined where possible.

Stale-While-Revalidate

Dashboard data uses SWR: serve stale cache immediately, revalidate in background. Configure via stale-while-revalidate=30 on API routes that power the user dashboard.

Cache Invalidation

License revocation triggers immediate purge via Upstash pub/sub. CDN cache is busted with surrogate-key tagging. Always invalidate by key, never by time alone.