Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent caching of non 200 responses in AWS API Gateway

Tags:

People also ask

How do I invalidate cache in AWS API gateway?

To invalidate an existing cache entry of a request and retrieve the latest data from the integration endpoint, one must send the request together with the Cache-Control: max-age=0 header.

Does API gateway cache requests?

With caching, you can reduce the number of calls made to your endpoint and also improve the latency of requests to your API. When you enable caching for a stage, API Gateway caches responses from your endpoint for a specified time-to-live (TTL) period, in seconds.

Should API responses be cached?

It improves response times: When a client repeatedly initiates an API without caching instructions, the API's response time is the same whether or not the data changes or not. An API with caching instructions speeds up response time because the client's first request is saved in the cache for future requests.


How should I go about disabling the cache of non 200 OK responses in API Gateway.

For one of our API endpoints we implemented our complementary throttle mechanism and we're sending a 429 HTTP response.

The intention is for the client to retry the request after a short time when the server is ready to fulfil it but what happens now is that the API Gateway caches the initial response and keeps sending that from cache instead.