Search code examples
androidamazon-cloudfrontaws-api-gateway

Continuous Miss from CloudFront


I am getting the following error "Miss from CloudFront" when I run the post request api from my android app. Although when I tested the api from postman it gave the same error but it did update the details in DynamoDb but when I run it on the mobile app it gives the same error but no updates in the DynamoDB. And also is it necessary to configure CloudFront with API Gateway?

The following is my android monitor verbose output:

content-type: application/json
content-length: 982
date: Sat, 06 May 2017 17:57:56 GMT
x-amzn-requestid: 88a875cd-3285-11e7-959a-1bb59a5dfddb
x-amzn-trace-id: sampled=0;root=1-590e0ea4-46e2415a5816996f8f61985f
x-cache: Miss from cloudfront
via: 1.1 7b637ad78977549938b508611f792222.cloudfront.net (CloudFront)
x-amz-cf-id: PA8VzPLzR823OAVOxT9bWgyIHdyue9-CAnXyLrWJY_7WMSB_xSdCEw==
OkHttp-Sent-Millis: 1494093475993
OkHttp-Received-Millis: 1494093476302
Status code: 200

Solution

  • X-Cache: Miss from cloudfront is not an error.

    It's only an informational header, and when seen with API Gateway, it has no meaning at all -- it's just a side effect of the fact that CloudFront always provides some front-end services for API Gateway. This arrangement is provisioned and controlled by API Gateway, so there is nothing to configure (also nothing that can be removed).

    In this case, you should disregard this response header -- the problem is somewhere else.

    As you noted, yourself, the message is still there when usimg Postman and yet the request works exactly as it should in that environment. Even without the above background information, this fact should suggest that this header is unrelated, since it's present whether the request succeeds in performing the back-end operation, or not.

    Similarly, if you have a back-end failure that throws an HTTP error code, the header would say X-Cache: Error from CloudFront. This means only that CloudFront is returning an error response which, in this case, comes from upstream -- if the error response is from API Gateway, then such a header does not mean that CloudFront is generating the error response.