Caching
Intelligent caching that improves performance automatically. Simple TTL-based caching with dynamic keys and automatic invalidation.
On this page
Caching That Just Works
Add caching to any route with one line.
Automatic TTL management, dynamic keys, and smart invalidation.
It's This Simple
Add caching with one line
typescript
Why Caching Matters
Without caching, every request hits your database or expensive operations. With caching, responses are instant.
Traditional caching requires manual setup, key management, and invalidation logic. We handle that automatically.
Without Caching
- •Every request hits the database
- •Slow response times
- •High server load
- •Manual cache management
With MoroJS
- •Instant responses from cache
- •Reduced database load
- •Automatic TTL management
- •One-line setup
It's This Easy
Add caching to any route. That's it.
Dynamic cache keys with parameters
typescript
Why It Makes Sense
Fast
Instant responses from cache. No database queries for cached data.
Automatic
TTL-based expiration. No manual cache management needed.
Simple
One line of code. Dynamic keys. Smart invalidation.
How It Works
MoroJS caching automatically stores responses based on cache keys and TTL (time-to-live) values. When a request comes in, it checks the cache first. If found, it returns immediately. If not, it executes the handler and stores the result.
Route-Level Caching
Basic Route Caching
typescript
Different TTLs for Different Data
typescript
Advanced Caching
For advanced use cases, you can integrate external caching solutions like Redis, implement tag-based invalidation, and manage cache manually.
Tag-Based Invalidation
typescript
Manual Cache Management
typescript