Why is my CloudFront distribution returning an “X-Cache:Miss from CloudFront” response?
Last updated: 2019-04-03
I configured my CloudFront distribution and origin to cache objects, but my distribution is returning an "X-Cache:Miss from CloudFront" response. What is causing this? What can I do to avoid this response?
To diagnose and troubleshoot the cause of the "X-Cache:Miss from CloudFront" response, check the following:
Which edge location is receiving the requests?
After an object is requested through Amazon CloudFront, the object is cached only in the edge location that received the request. If a subsequent request is made to another edge location, the other edge location won't have a cached version of the object, and so it returns an "X-Cache:Miss from CloudFront" response.
To determine if the response is coming from one edge location or from multiple edge locations, send several requests from the same client to the same object. Then, check the IP addresses that the connection is established on. Run a reverse DNS lookup on the IP addresses to determine which edge location the requests are going to.
How frequently is the object requested?
If an object in an edge location isn't requested frequently, CloudFront might remove the object before its expiration date. For more information on when CloudFront evicts objects, see Managing How Long Content Stays in an Edge Cache (Expiration).
If you're seeing the "X-Cache:Miss from CloudFront" response intermittently, CloudFront might be removing the object because of infrequent requests.
Is the CloudFront distribution configured to forward any headers, cookies, or query string parameters?
If your distribution is configured to forward headers, cookies, or query string parameters, then the distribution caches requests based on those parameters. The parameters reduce the number of requests served from the cache.
For example, if two requests to access an object have different values in query string parameters, then the second request won't be served from the cache. The second request returns the "X-Cache:Miss from CloudFront" response.
To determine if forwarding headers, cookies, or query string parameters are causing the response, configure the CloudFront distribution to not forward these parameters to the origin. Then, check to see if the issue persists.
If the issue resolves after the distribution no longer forwards those parameters, then at least one parameter is causing the response. Consider whitelisting only the specific parameters you want CloudFront to forward to the origin, rather than configuring CloudFront to forward a wide range of parameters.
Is the response stored in the browser cache?
After a request results in the "X-Cache:Miss from CloudFront" response, the browser might be serving the same response to subsequent requests because it's stored in the browser cache.
To verify if the response is stored in the browser cache, clear the browser cache and make a new request for the same object.
Note: To determine how long the browser caches the object, check to see if any Cache-Control or Expires headers are set on the object.