← Back to Browse
Performance
CacheLayer
Smart caching middleware with automatic invalidation, stale-while-revalidate, and cache warming.
★★★★★ 4.6
256 reviews
9.4k
installs
v1.7.0
MIT
Install
npx skilldock install cache-layer
About
CacheLayer adds intelligent caching to your Express APIs with zero config. It detects cacheable responses, implements stale-while-revalidate for instant responses, auto-invalidates on mutations, and supports Redis, Memcached, or in-memory stores. Includes cache hit/miss metrics.
Usage Example
const { cache } = require("cache-layer");
// Auto-cache GET routes
app.use(cache({
ttl: "5m",
staleWhileRevalidate: "1h",
invalidateOn: ["POST", "PUT", "DELETE"],
store: "memory" // or "redis"
}));