API Gateway Max Cached Response Size

0

I am testing API Gateway cache behavior for an API with Lambda integration. The documentation clearly states (here and here) that "The maximum size of a response that can be cached is 1048576 bytes," in other words just over 1 MB. I am testing by adding a header to the Lambda response containing a timestamp--if the timestamp remains the same across requests, this would indicate that the response was retrieved from the cache and the Lambda was not invoked.

The problem I'm encountering is that during testing, the API cache behavior does not seem to align with the documented response size limits--it seems to be caching responses that are over 5 MB in size. Am I misunderstanding this limit, or can anyone shed any light on what is going on here?

1 Answer
0

Hi, @jeffgardnerdev.

I think your guess is correct. very interesting.

The document below also states that the capacity varies depending on the cache instance.
Can you measure what your current maximum cache size is?

https://aws.amazon.com/premiumsupport/knowledge-center/api-gateway-cache-capacity/?nc1=h_ls

Are your API Gateway resources edge-optimized? Are you regional?
In the latter case, have you additionally introduced CloudFront, etc.?
In that case, check the access log of API Gateway and check whether it is cached by CloudFront.

profile picture
EXPERT
iwasa
answered 3 months ago
  • @iwasa thanks for the response. I am testing with a regional API, no CloudFront, using the minimum cache size--0.5 GB. Cache is not encrypted and TTL is set to 3600. I have tested after clearing the cache and the results are consistent.

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