Performance: TTL configuration
MEDIUM IMPACT
TTL configuration affects how long cached data stays valid, impacting page load speed and server response times by controlling cache freshness.
cacheManager.set('key', data, { ttl: 60 }); // cache expires after 60 seconds
cacheManager.set('key', data, { ttl: 0 }); // no expiration, cache never clears
| Pattern | Cache Freshness | Memory Usage | Server Load | Verdict |
|---|---|---|---|---|
| No TTL (cache never expires) | Stale data | High | High | [X] Bad |
| Short TTL (e.g., 60 seconds) | Fresh data | Controlled | Low | [OK] Good |