What is the feature you are proposing?
Problem:
Issue #3857 correctly identifies that Hono's existing cache() middleware only works on Cloudflare Workers (via Cache API) and has no storage adapter support. Node.js and Bun apps must implement their own caching from scratch.
This is the single most-requested missing piece for teams using Hono in production on non-Cloudflare runtimes.
What I want to build:
A universal @hono/cache middleware with a storage adapter interface:
import { cache } from '@hono/cache';
import { RedisStore } from '@hono/cache/redis';
import { createClient } from 'redis';
const redis = createClient();
await redis.connect();
app.use('/api/*',
cache({
store: new RedisStore({ client: redis }),
ttl: 60, // seconds
keyGenerator: (c) => c.req.url, // default: full URL
vary: ['Authorization'], // cache-bust on these headers
condition: (c) => c.req.method === 'GET', // only cache GETs
})
);
Adapters I'll build:
MemoryStore — in-process LRU cache (default, zero deps)
RedisStore — wraps redis or ioredis client (peer dep)
CloudflareKVStore — uses KV namespace (existing behavior, migrated to adapter)
BaseStore — abstract class for custom implementations
API contract:
interface CacheStore {
get(key: string): Promise<CacheEntry | null>;
set(key: string, entry: CacheEntry, ttlSeconds: number): Promise<void>;
delete(key: string): Promise<void>;
}
Why not hono-rate-limiter's approach:
The community hono-rate-limiter shows there's demand for pluggable adapters. An officially maintained @hono/cache with the same adapter pattern would give Hono the production-ready caching story it's missing for Node.js/Bun deployments.
I'll submit a PR to honojs/middleware once the design is approved. Should this live in hono/cache (core) or @hono/cache (middleware repo)?
What is the feature you are proposing?
Problem:
Issue #3857 correctly identifies that Hono's existing
cache()middleware only works on Cloudflare Workers (via Cache API) and has no storage adapter support. Node.js and Bun apps must implement their own caching from scratch.This is the single most-requested missing piece for teams using Hono in production on non-Cloudflare runtimes.
What I want to build:
A universal
@hono/cachemiddleware with a storage adapter interface:Adapters I'll build:
MemoryStore— in-process LRU cache (default, zero deps)RedisStore— wrapsredisorioredisclient (peer dep)CloudflareKVStore— usesKVnamespace (existing behavior, migrated to adapter)BaseStore— abstract class for custom implementationsAPI contract:
Why not
hono-rate-limiter's approach:The community
hono-rate-limitershows there's demand for pluggable adapters. An officially maintained@hono/cachewith the same adapter pattern would give Hono the production-ready caching story it's missing for Node.js/Bun deployments.I'll submit a PR to
honojs/middlewareonce the design is approved. Should this live inhono/cache(core) or@hono/cache(middleware repo)?