Reputation: 444
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.
Upvotes: 2
Views: 13574
Reputation: 270114
Amazon CloudFront is a 'pull-through cache'. This means that there is initially nothing in the cache.
It works like this:
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.
Upvotes: 2