Closed marc-parillo closed 3 years ago
Hi @marc-parillo,
Thanks for your help. I combined this with a related PR and added a few more tests. It should now be solved in the latest version 1.6.1.
Please note that setting ttlInSeconds: 0
on global cache or function cache has the same effect as setting enabled: false
. Using a boolean is the recommended way of disabling caching, because it explicitly says that caching is disabled, as opposed to having to figure that out by reading a completely different property like ttlInSeconds
.
Also, if you enable apiGatewayCaching
globally, you must specify which endpoints to enable caching for, otherwise it's disabled by default.
For example:
plugins:
- serverless-api-gateway-caching
custom:
apiGatewayCaching:
enabled: true
functions:
list-cats:
handler: rest_api/cats/get/handler.handle
events:
- http:
path: /cats
method: get
# caching is enabled
caching:
enabled: true
update-cat:
handler: rest_api/cat/post/handler.handle
events:
- http:
path: /cat/{pawId}
method: post
# caching is disabled by default
I discovered that we can't set 0 for TTL so I adjusted
ApiGatewayCachingSettings.js
to allow for this. In some cases, we want to enable caching for only a few endpoints in the Stage. So, the main Stage caching is set totrue
with TTL 0 and other endpoints you want to cache can be set to a different TTL.