Once you configure CloudFront to deliver your content, here's what happens when users request your objects:
- A user accesses your website or application and requests one or more objects, such as an image file and an HTML file.
- CloudFront determines which edge location can best serve the user's request, typically the nearest CloudFront edge location in terms of latency, and routes the request to that edge location.
- In the edge location, CloudFront checks its cache for the requested files. If the files are in the cache, CloudFront returns them to the user. If the files are not in the cache, it does the following:
- CloudFront compares the request with the specifications in your distribution and forwards the request for the files to the applicable origin server for the corresponding file type—for example, to your Amazon S3 bucket for image files and to your HTTP server for the HTML files.
- The origin servers send the files back to the CloudFront edge location.
- As soon as the first byte arrives from the origin, CloudFront begins to forward the files to the user. CloudFront also adds the files to the cache in the edge location for the next time someone requests those files.
- After an object has been in an edge cache for 24 hours or for the duration specified in your file headers, CloudFront does the following:
- CloudFront forwards the next request for the object to your origin to determine whether the edge location has the latest version.
- If the version in the edge location is the latest, CloudFront delivers it to your user.If the version in the edge location is not the latest, your origin sends the latest version to CloudFront, and CloudFront delivers the object to your user and stores the latest version in the cache at that edge location.
Comments