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, while "X-Cache:Hit from cloudfront" is returned when requests are served from the closest CloudFront 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, be sure that the directives are consistent with the Minimum TTL, Maximum TTL, or Default TTL set on the CloudFront 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 and use Amazon Route 53 to route origin requests to the closest location.

If you're still seeing slow downloads from CloudFront after updating your configurations as recommended, you can gather the required information and contact AWS Support.


Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center

Published: 2018-06-29