cache global with ttl = 0 nor working
Closed this issue · 2 comments
when setup ttlInSeconds: 0
and deploy code, deployed cache ttl is 3600 , because const DEFAULT_TTL = 3600;
it is not possible to implement ttl = 0 and this can be very useful to enable global cache without storage but if cache on specific endpoints
Thanks for raising this issue.
I'm not entirely sure I understand your use-case, would you mind giving me an example of how setting TTL to 0 can help you?
Values of zero for ttlInSeconds
should now be supported in v1.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