mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 21:32:05 +00:00
Implemented cache control API:
- cache: false - Disables caching entirely (compress on-demand, not cached)
- cache: { maxSize, ttl, minEntrySize, maxEntrySize } - Configure limits
- --smol mode automatically uses conservative defaults
Cache Configuration:
- DEFAULT: 50MB max, 24h TTL, 128B-10MB per entry
- SMOL: 5MB max, 1h TTL, 512B-1MB per entry (for --smol flag)
- cache: false - Skip caching, return false from tryServeCompressed()
API Example:
```js
Bun.serve({
compression: {
brotli: 6,
cache: false, // Disable caching
cache: {
maxSize: 100 * 1024 * 1024, // 100MB
ttl: 3600, // 1 hour (seconds)
minEntrySize: 512,
maxEntrySize: 5 * 1024 * 1024,
}
}
})
```
Limitations (TODO):
- Cache limits are parsed but not enforced yet
- No TTL checking or eviction
- No total size tracking or LRU eviction
- cache: false works immediately
The configuration exists and --smol defaults are in place, ready for
enforcement implementation later.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>