@interlace/serverless
API Gateway Caching

Configuration Reference

Complete reference for all global and per-endpoint caching settings.

Global Settings

Configure under custom.interlaceCaching in your serverless.yml:

custom:
  interlaceCaching:
    enabled: true
    clusterSize: '0.5'
    ttlInSeconds: 300
    dataEncrypted: false
    flushOnDeploy: false
    perKeyInvalidation:
      requireAuthorization: true
      handleUnauthorizedRequests: Ignore
    endpointsInheritCloudWatchSettingsFromStage: true

Properties

PropertyTypeDefaultDescription
enabledbooleanfalseEnable the cache cluster
clusterSizestring'0.5'Size in GB: 0.5, 1.6, 6.1, 13.5, 28.4, 58.2, 118, 237
ttlInSecondsnumber300Default TTL (0–3600)
dataEncryptedbooleanfalseEncrypt cached data at rest
flushOnDeploybooleanfalseFlush cache after every deploy
sharedApiGatewaybooleanfalseSkip stage-level cluster changes
restApiIdstringautoExplicit REST API ID
basePathstringPath prefix for shared gateways
endpointsInheritCloudWatchSettingsFromStagebooleantrueCopy CloudWatch settings to methods
perKeyInvalidationobjectDefault invalidation settings
additionalEndpointsarray[]CF-defined endpoints to cache

Cache Cluster Sizes

The plugin enum-validates clusterSize to the AWS-allowed values:

'0.5', '1.6', '6.1', '13.5', '28.4', '58.2', '118', '237' (all GB).

For pricing per size, refer to the official API Gateway pricing page under "API caching" — AWS publishes per-region rates and the numbers change. We don't restate them here so the docs don't drift out of sync with what you'll actually be billed.

Per-Endpoint Settings

Configure on each HTTP event:

functions:
  getUser:
    handler: src/handler.get
    events:
      - http:
          path: /users/{id}
          method: get
          caching:
            enabled: true
            ttlInSeconds: 600
            dataEncrypted: true
            inheritCloudWatchSettingsFromStage: false
            perKeyInvalidation:
              requireAuthorization: true
              handleUnauthorizedRequests: Fail
            cacheKeyParameters:
              - name: request.path.id

Properties

PropertyTypeDefaultDescription
enabledbooleanfalseEnable caching for this endpoint
ttlInSecondsnumberglobalOverride TTL
dataEncryptedbooleanglobalOverride encryption
inheritCloudWatchSettingsFromStagebooleantrueOverride CloudWatch inheritance
perKeyInvalidationobjectglobalOverride invalidation settings
cacheKeyParametersarray[]Cache key parameters

Per-Key Cache Invalidation

Control how clients invalidate specific cache entries using the Cache-Control: max-age=0 header:

StrategyBehavior
IgnoreSilently ignore unauthorized invalidation
IgnoreWithWarningIgnore but add a Warning response header
FailReturn 403 Forbidden

ANY Method Behavior

For HTTP method ANY, caching is enabled only for GET and explicitly disabled for DELETE, HEAD, OPTIONS, PATCH, POST, and PUT.

On this page