How do I reduce the latency of requests that receive the response "X-Cache:Miss from cloudfront"?

Last updated: 2019-06-21

I'm seeing high latency when objects or images are downloaded from Amazon CloudFront. Requests that receive the "X-Cache:Miss from cloudfront" response are slower to load than requests that receive the "X-Cache:Hit from cloudfront" response. Why is this happening? How can I fix this? 


CloudFront returns "X-Cache:Miss from cloudfront" when the request is sent to the origin. CloudFront returns "X-Cache:Hit from cloudfront" when requests are served from the closest edge location. "Miss" requests might be slower to load because of the additional step of forwarding to the origin.

To avoid latency from forwarding requests to the origin, check the following to be sure that requests can be served from CloudFront edge locations:

  • Don't forward all headers, all cookies, or all query strings, because this directs CloudFront to pass through requests instead of caching them.
  • Verify that any whitelisted headers or cookies are whitelisted. Remove any unnecessary headers or cookies from their respective whitelist to improve caching.
    Note: For web distributions, CloudFront by default doesn't consider cookies when caching objects in edge locations. If your origin returns two objects and they differ only by the values in the Set-Cookie header, CloudFront caches only one version of the object.
  • Extend the Minimum TTL, Maximum TTL, or Default TTL for path patterns that need more time in the cache before CloudFront queries the origin.
  • If your origin uses Cache-Control headers, verify that the directives are consistent with the Minimum TTL, Maximum TTL, or Default TTL set on the distribution.
  • If your origin uses the Expires header, verify that the header allows CloudFront to cache responses as needed.
  • Verify that your origin server sets valid, accurate values for the Date and Last-Modified header fields.
  • Limit the use of invalidations on objects. Run invalidations only when necessary.
  • Check how frequently objects are requested. If an object is not requested often, CloudFront might remove the object from an edge location.

To help reduce latency from "Miss" requests, you can also set up more origin servers that are geographically closer to your requesters. Then, you can use Amazon Route 53 to route origin requests to the closest location.