AWS CloudFront Caching implementing Dynamic Content from API Gateway
I'm working with a question with AWS CloudFront caching behavior for dynamic content served from API Gateway. I have set up a CloudFront distribution that points to my API Gateway endpoint, expecting it to cache responses based on the query parameters. However, it seems that every request is hitting the API Gateway directly, even when the responses should be cacheable. My CloudFront distribution has caching behavior settings defined as follows: 1. Cache based on query string parameters: Enabled 2. Default TTL: 3600 seconds 3. Max TTL: 86400 seconds I also have the following custom header configured to control the cache: ```json { "Cache-Control": "max-age=3600" } ``` Additionally, I ensured that my API Gateway method settings allow for caching: - Caching is enabled for the GET method. - I have set the 'Cache key parameters' to include specific query string parameters. Despite these configurations, I keep seeing the following behavior in my CloudWatch logs: `514: The origin response is not cacheable.` I tried invalidating the cache manually and also deployed new versions of my API, but it did not resolve the scenario. Can anyone suggest why CloudFront might not be caching the responses as expected or how I can debug this further? Any insights into best practices for caching dynamic content would be very helpful!