How do I set the cache key for the AWS API Gateway?

Question:

I have a Lambda function that is mapped to a HTTP endpoint using the AWS API Gateway. This works fine, I have mapped query string params to the Lambda event, everything works:

https://api.buzzcloud.xyz/?count=999

Which I can call from http://buzzcloud.xyz

I would like to enable caching, but it seems that by default the API Gateway uses the URL for caching, and so changes in my query string parameters are not triggering a different cache result.

The result is that with caching on, my page returns whatever data was first requested and put in the cache.

How do I set a custom cache key or ensure querystring is part of the cache identifier?

Answer:

Turns out the is a not-so-secret setting that I totally missed that allows for the exact query string params that should be used for the cache to be set.

Set Cache for URL Query String Params

Leave a Reply