What is the feature you are proposing?
Problem
Hono's current cache middleware implementation has two key limitations:
- Platform-specific dependency (Cloudflare/Deno only)
- Lack of storage adapter support (Redis, Memory, Filesystem, etc.)
This forces developers to:
- Write custom caching solutions for Node.js/Bun environments
- Re-implement cache layers for different storage backends
- Maintain inconsistent caching patterns across projects
Proposal: Universal Cache Middleware
Implement a flexible caching system inspired by Nitro's cache implementation with:
Storage Adapter Interface
Support pluggable adapters for:
- Redis
- In-memory (default)
- Filesystem
- Cloudflare KV/Deno KV
- Custom implementations
Unified Configuration
// Global configuration
const app = new Hono({
cache: {
storage: 'redis',
ttl: 3600,
redisOptions: { ... }
}
})
// Per-route configuration
app.get('/data',
cache({
storage: 'memory',
ttl: 60,
vary: ['Authorization']
}),
handler
)
Core Features
- TTL management
- Cache-Control header synchronization
- Vary header support
- Cache key generation strategies
- Multi-platform support (Node, Bun, Deno, Cloudflare, etc.)
Why This Matters
- Framework Completeness: Modern frameworks like Next.js, Nuxt, and Astro include robust caching solutions. Hono needs equivalent capabilities to be considered production-ready for full-stack applications.
- Developer Experience: Reduce boilerplate for common caching patterns:
// Current workaround
let data
if (await cache.exists(key)) {
data = await cache.get(key)
} else {
data = normalDataRetriving()
await cache.set(key, data)
}
Performance Critical
Proper caching is essential for:
- API response caching
- SSR/SSG optimizations
- Reducing expensive operations/API calls
- Platform Agnosticism
Aligns with Hono's core philosophy of universal compatibility across runtimes.
Implementation Considerations
Storage Adapter Interface Proposal
interface CacheStorage {
get(key: string): Promise<Response | null>
set(key: string, response: Response, options?: CacheOptions): Promise<void>
delete(key: string): Promise<void>
}
Priority Adapters
- Memory (default)
- Redis (with popular clients)
- Filesystem (Node/Bun)
- Cloudflare KV
Other considerations:
- Automatic TTL handling from Cache-Control headers
What is the feature you are proposing?
Problem
Hono's current cache middleware implementation has two key limitations:
This forces developers to:
Proposal: Universal Cache Middleware
Implement a flexible caching system inspired by Nitro's cache implementation with:
Storage Adapter Interface
Support pluggable adapters for:
Unified Configuration
Core Features
Why This Matters
Performance Critical
Proper caching is essential for:
Aligns with Hono's core philosophy of universal compatibility across runtimes.
Implementation Considerations
Storage Adapter Interface Proposal
Priority Adapters
Other considerations: