Closed toddpla closed 1 year ago
Hi @toddpla,
Thanks for asking.
Yes, the serverless-api-gateway-caching
plugin can work with the serverless-apigateway-service-proxy
.
There's a feature which allows configuring caching for endpoints that are not defined as lambda functions. The example in this plugin's readme shows a proxy endpoint defined in CloudFormation syntax, but the same kind of configuration works no matter how endpoints are defined.
In yml, the plugins working together might look like this:
plugins:
- serverless-api-gateway-caching
- serverless-apigateway-service-proxy
custom:
apiGatewayCaching:
enabled: true
additionalEndpoints:
- method: GET
path: /dynamodb # needs to match the path defined in apiGatewayServiceProxies
caching:
enabled: true
apiGatewayServiceProxies:
- dynamodb:
path: /dynamodb
method: get
tableName: { Ref: 'MyDynamoTable' }
hashKey:
queryStringParam: id # use query string parameter
attributeType: S
action: GetItem
additionalEndpoints
feature does not currently support configuring cache key parameters.If you call /dynamodb?id=1
, it will cache the result for id=1
. If you then call /dynamodb?id=2
, it will retrieve the result it had cached for id=1
until the cache time to live expires. Based on your requirements, you may wish to wait for this feature to be added before using these plugins side by side.
Released in 1.9.0
Is this plugin able to be configured with serverless-apigateway-service-proxy?
Specifically I would like to enable caching of a dynamodb GET request via an API Gateway proxy.