Can the AWS API Gateway cache invalidate specific entries based on response content?

I used the AWS API Gateway with the endpoint as a lambda function. I have included the caching features provided by the API gateway in order to reduce the response time and the number of calls redirected to my lambda function.

The lambda function requests another data store to return data. If no data is found, an asynchronous call is made to update the data store, and "data not found" is returned to the caller. Now the API gateway even caches this result, which we do not want. This leads to the fact that the cache always returns “data not found” for its lifetime (1 hour TTL), even if the data is updated asynchronously in the data warehouse.

I know the request header (Cache-Control: max-age = 0), which can invalidate the cache and receive a response directly from Lambda, as indicated in this.

But this will not be useful, because the caller does not know whether the data is present in the data warehouse or not, and therefore cannot selectively send such a request header.


So my 2 questions:

  • Is the API gateway caching another HTTP response, for example, 404 (except 200)?
  • Can I tell the API gateway not to cache specific responses?
+1
source share
1 answer
  • As you noticed, the Gateway API caches the result of your endpoint regardless of the status code.

  • , . , , , .

API Gateway 404, , ? - , API, , API , API Gateway.

0

Source: https://habr.com/ru/post/1684480/


All Articles