@interlace/serverless
API Gateway Caching

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-caching
pnpm add -D @interlace/serverless-api-gateway-caching
yarn add -D @interlace/serverless-api-gateway-caching
bun add -d @interlace/serverless-api-gateway-caching

Why 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:

CapabilityCommunity plugin@interlace
before:remove:remove cleanup hook❌ ghost billing
sls caching flush / status / disable / preview
Auto-flush on deployflushOnDeploy: true
Jittered retry (no thundering herd)❌ pure exponential
ANY method → GET-only caching❌ partial
Zero runtime dependencieslodash.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.id

Enabling 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.

Next Steps

On this page