☁️ AWS

Updated at 2015-08-19 04:06

CloudFront allows you to create distributions. You can imagine that distribution is a server that caches and delivers content from another server behind the distribution. The server behind distribution is called origin, location where the original version of your content is stored.

# Origin:
# Distribution:

CloudFront increases content download speed world wide. You can choose to have distribution endpoints in all major geographical areas EU, US, Asia etc.

Distributions can additionally:

  • we given custom domain e.g.
  • require HTTPS
  • keep access logs
  • forward cookies or query strings to the origin
  • limit access to specific user
  • limit access by user country

There are two distribution types:

  • Web Distribution: Downloadable media content like .html, .css, .png, .avi. Linked to S3, EC2 or custom HTTP/HTTPS server.
  • RTMP Distribution: Streamable media content using Real-Time Media Protocol. Must be linked to a S3.
HTTP Server (Origin)
    Internet           (the first time file is requested)
AWS CF (Distribution)
AWS S3 (Files)
    Internet          (the first time file is requested)
AWS CF (Distribution)

To create a distribution:

  1. Go to AWS CloudFront Console > Distributions.
  2. Click Create Distribution.
  3. Define your origin.
  4. Other settings are optional e.g. distribution areas and logging.
  5. Start it and wait for it to be deployed.
  6. Use distribution Domain Name to serve the assets.

Distributions can also have multiple origins. You use paths to assign individual content to specific origin.

Origin 1:
Origin 2:

Behaviour 3:  Content beginning with /images/ are found in origin 2.
Behaviour 2:  Content matching *.jpg are found in origin 2.
Behaviour 1:  All the rest of the content is found in origin 1