By using AWS re:Post, you agree to the AWS re:Post Terms of Use

AWS API Gateway: Enable caching only for one endpoint, not by the stage

0

Hello There,

I am looking to enable caching at AWS Gateway for a specific endpoint/resource within the API deployment, not by the whole stage. Let's say - The API configured on the gateway has following endpoints

GET /choices GET /products/{id} GET /options

I want to enable caching only for GET /products/{id} but not for the other two resources.

One way, I understand is that, I can always enable caching at stage level, and then go and override for individual endpoints/resources not to have the caching. However, in this example, I only have three endpoints, but in my actual scenario, I have a legacy api that has more than 70 resources. So, overriding most of those not to have the caching is kind of daunting.

Maybe automate using the aws api to override the caching for those resources that are not required would be an option. However, Is there a way we can enable caching only for those endpoints that we want them to use cache without enabling at stage level. I would like to have that flexibility.

Appreciate any suggestions.

Thanks

1 Answer
0

I am not sure if this is what your looking for or if I understand correctly. Maybe this will help you

  • Open the API Gateway console and select your API.

  • Click on the resource that contains the endpoint you want to enable caching for (in your case, this would be the resource containing the GET /products/{id} endpoint).

  • Click on the method (GET in this case) for the endpoint.

  • Under the Method Execution pane, expand the Caching section.

  • Enable caching by selecting Enable API caching and configuring the Cache Settings. You can set the Cache Time-to-Live (TTL) and the Cache Data Encrypted options based on your requirements.

  • Save the changes to the method.

Now, the GET /products/{id} endpoint will use caching, while the other endpoints will not.

Enabling caching at the method level will override the settings at the stage level.

answered 2 years ago
  • Thanks for the reply. However, I do not see an option under API execution pane to configure caching for any endpoint or the resource. The option we get there is to enable caching for any query, path parameters and headers. Those configuration are only to enable caching by params. Which means if you expect GET /products/1111 to be different than GET /products/1112. Anyway, the option to enable caching is only under the stage settings and then you go to individual endpoint under the stage to override the caching option (the overriding the caching becomes available only after enabling caching at the stage level)

  • We are unable to do caching with above solution in API Gateway, please suggest the way to enable caching in API Gateway. the navigations that are provided are not working.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions