Caching Plugin
API Gateway caching for Serverless Framework — done right.
Overview
@interlace/serverless-api-gateway-caching is a TypeScript-native replacement for serverless-api-gateway-caching that fixes ghost billing, adds CLI commands, and provides full config validation.
Supports Serverless Framework v3 and v4 out of the box — runtime and TypeScript types. The exported config types (CachingPluginConfig, EndpointCachingConfig) work from serverless.ts regardless of framework version.
npm install --save-dev @interlace/serverless-api-gateway-cachingpnpm add -D @interlace/serverless-api-gateway-cachingyarn add -D @interlace/serverless-api-gateway-cachingbun add -d @interlace/serverless-api-gateway-cachingWhy switch?
Everything the community plugin does, plus the things it does badly or not at all. See the migration guide for the full feature-by-feature comparison.
Headline differences:
| Capability | Community plugin | @interlace |
|---|---|---|
before:remove:remove cleanup hook | ❌ ghost billing | ✅ |
sls caching flush / status / disable / preview | ❌ | ✅ |
| Auto-flush on deploy | ❌ | ✅ flushOnDeploy: true |
| Jittered retry (no thundering herd) | ❌ pure exponential | ✅ |
ANY method → GET-only caching | ❌ partial | ✅ |
| Zero runtime dependencies | ❌ lodash.isempty | ✅ |
| No prototype pollution | 🔴 monkey-patches String.prototype.replaceAll | ✅ |
| TypeScript types & IntelliSense | ❌ | ✅ |
Quick Start
plugins:
- '@interlace/serverless-api-gateway-caching'
custom:
interlaceCaching:
enabled: true
clusterSize: '0.5'
ttlInSeconds: 300
functions:
getUser:
handler: src/handler.get
events:
- http:
path: /users/{id}
method: get
caching:
enabled: true
cacheKeyParameters:
- name: request.path.idEnabling caching globally does not automatically cache all endpoints — you must set caching.enabled: true on each endpoint individually.
REST API Only
This plugin only supports REST API (http events). HTTP API (httpApi) does not support API Gateway caching. See AWS docs.