简体   繁体   中英

x-cache: Miss from cloudfront in AWS

I am serving images from s3 via CloudFront. when I inspect I am still getting a message x-cache: Miss from CloudFront It would be great if someone could assist how to configure it in the right way so images would server from CloudFront cache.

在此处输入图像描述

Amazon CloudFront is a 'pull-through cache'. This means that there is initially nothing in the cache.

It works like this:

  • A user requests a resource (eg HTML page or an image) via a CloudFront URL
  • The request is sent to a nearby CloudFront edge location
  • The edge location checks its local cache -- if the requested resource is found, it is returned to the user ('Hit')
  • Otherwise, it forwards the request to a regional cache -- if the requested resource is found, it is returned to the edge location, which stores it in its local cache. The resource is then returned to the user.
  • If the resource was not found in the regional cache, the request is forwarded to the Origin , which returns the resource. It is then stored in the regional cache and returned to the edge location, which stores it and returns it to the user.

Therefore, items are only stored in the cache when they are first requested. Plus, they are only stored in the edge location that was accessed by the user. So, if a user in Paris requests the resource, it will be stored in their edge location. But, when a user in Auckland requests the same resource, it will not be in their local cache until it is accessed by a nearby user.

Items remain in the cache for a period of time based on the recency of requests and the size of the object. CloudFront has very big caches -- they even cache Prime Video movies!

So, the answer to your question about how to configure CloudFront to serve images from the cache is that there is nothing to configure -- it will be done automatically when a resource is first requested. Just run your command again and you'll see that it was a 'Hit' from the cache.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM