DianaIonita/serverless-api-gateway-caching

Getting a bunch of APIs with "Inherit from stage" unexpectedly

Closed this issue · 4 comments

Unsure of when this happened, but we just recently discovered that a couple of our APIs have changed to "Inherit from stage" setting even though we're not even using this caching plugin on these specific APIs.

Any support you can provide to help us find out what is causing this would be greatly appreciated please.

Have had this on 1.8.1 and 1.10.1 versions.

Hi @gligorkot,

Thanks for raising an issue.
Can you please walk me through what your setup is? Are you using the plugin across multiple projects? Can you share some of your serverless.yml please?

Hi @DianaIonita,

Thanks for getting back to me. We actually resolved the issue, but probably worth chatting about it.

Our setup has about 14 or 15 cloud formation stacks in a services folder. All of them use a common custom serverless vars file where apiGatewayCaching.enabled is set to true. What we noticed in one of our recent deployments was that some of the API Gateway routes (in one of the services where we didn't have caching at all and weren't using the api gateway caching plugin) were getting set up as "Inherit from stage", and because the stage had the default caching of 3600 set, we were getting caching across routes that were never supposed to have caching on.

To fix this, we set our default ttlInSeconds: 0 as suggested by your documentation as well as added the api gateway caching plugin on all our CF stacks even when we don't have any caching set up for them. This works, but I was wondering how this used to work before and not now as this was a very recent issue we found.

Cheers,
G

Hi @gligorkot,

Thanks for your description of your setup!
I can confirm that, in v1.9.0 of the plugin, I fixed an issue where shared API gateway endpoint settings were not being properly inherited from stage settings. I'm not sure why it appeared to work for you before, but it may have had to do with those changes.

we set our default ttlInSeconds: 0 as suggested by your documentation as well as added the api gateway caching plugin on all our CF stacks even when we don't have any caching set up for them.

You don't need the caching plugin in stacks where you don't want caching configured.
When you create an endpoint in API Gateway, the caching settings are set to "Inherit from stage" by default. If you're working on a project where you create endpoints that reference a shared API Gateway and you don't want to configure caching at all, then those endpoints will inherit their caching settings from the stage settings. This means that caching will be enabled but with a time to live (TTL) of 0 seconds, effectively disabling caching. Again, this is default behaviour and the plugin wouldn't need to do anything.

Best wishes,
Diana

Thanks for replying @DianaIonita, yeah it appears to have happened around that time. No worries, it got me researching a bit more into it and figuring out a solution that works correctly. Thanks for your continued support on this plugin.