What is Origin in CloudFront: Simple Explanation and Example
CloudFront, an origin is the source location where your content lives, such as an S3 bucket or a web server. CloudFront fetches content from this origin to deliver it quickly to users worldwide.How It Works
Think of CloudFront as a delivery service and the origin as the warehouse where your products (content) are stored. When someone orders a product, CloudFront goes to the origin to get it and then delivers it to the customer.
The origin can be an AWS S3 bucket, an HTTP server, or other storage locations. CloudFront caches copies of your content at edge locations near users to speed up delivery. When a user requests content, CloudFront first checks if it has a cached copy; if not, it fetches it from the origin.
Example
This example shows how to define an origin in a CloudFront distribution using AWS CloudFormation. It sets an S3 bucket as the origin for the distribution.
Resources:
MyCloudFrontDistribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Enabled: true
Origins:
- Id: MyS3Origin
DomainName: my-bucket.s3.amazonaws.com
S3OriginConfig: {}
DefaultCacheBehavior:
TargetOriginId: MyS3Origin
ViewerProtocolPolicy: redirect-to-https
AllowedMethods:
- GET
- HEAD
CachedMethods:
- GET
- HEADWhen to Use
Use an origin in CloudFront whenever you want to deliver content like websites, videos, or files to users quickly and reliably. The origin is where your original content is stored.
Common use cases include:
- Serving a static website hosted in an S3 bucket.
- Delivering media files from a web server.
- Using a custom origin server for dynamic content.
CloudFront improves performance by caching content from the origin closer to users worldwide.
Key Points
- An origin is the source of your content for CloudFront.
- It can be an S3 bucket, HTTP server, or other storage.
- CloudFront fetches content from the origin when needed.
- Origins are configured when creating a CloudFront distribution.
- Caching at edge locations reduces load on the origin and speeds delivery.