I configured my Amazon CloudFront distribution and origin to cache objects. However, I receive an "X-Cache: Miss from CloudFront" response.
Resolution
Check the edge location that receives the requests
When CloudFront requests an object, CloudFront caches the object only in the edge location that received the request. When the viewer or client makes a subsequent request to another edge location, that edge location won't have a cached version of the object. You receive the "X-Cache: Miss from CloudFront" response.
To check if the response comes 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 see each edge location that the requests go to.
Or, to check the edge location, make a request to your CloudFront distribution and then check the x-amz-cf-pop value in the response.
Check how frequently the object is requested
If an object in an edge location isn't requested frequently, then CloudFront might remove the object before its expiration date. For more information on when CloudFront removes objects, see Manage how long content stays in the cache (expiration).
Check your CloudFront distribution configuration
If you configured your distribution to forward headers, cookies, or query strings, 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 query string values, then the second request isn't served from the cache. The second request returns the "X-Cache: Miss from CloudFront" response.
To check for this issue, first configure the CloudFront distribution to not forward headers, cookies, or query strings to the origin. Then, check if you still receive an X-Cache: Miss response. If you don't, then at least one parameter is the issue. Add the parameters that you want CloudFront to forward to the allowlist.
Check if the response is stored in the browser cache
If you receive the X-Cache: Miss response, then the browser might send the same response on subsequent requests because it's stored in the browser cache. Clear your browser cache, and then make a new request for the same object.
Check if the origin returns Cache-Control or Expires headers
If you configured your origin to return a Cache-Control or Expires header, then the object might expire or cache for a shorter duration.
To check how long the CloudFront and the browser cache the object, check if the object has Cache-Control or Expires headers.