Repository navigation
Technologies Cloudfront
Rhett Lowe edited this page Apr 20, 2020
·
3 revisions
AWS Cloudfront is a public facing Content Distribution/Delivery Network (CDN). That means it stands between the public internet and your private files. CDNs also cache and in many cases protect the files from hacks or attacks, such as Distributed Denial of Service (DDoS). This CDN also terminates SSL/TLS, helping to prevent Man in the Middle attacks.
Since it's caching your files you might ask "How long does it take for my file changes to appear on the site?" For three reasons, this shouldn't be a problem:
- you should be developing locally and uploading changes to a live/staging version, so your most frequent changes should be tested before uploading.
- CDNs have a way of communicating with the server to know when files change. They communicate that something is different and to invalidate either the changed files or the whole site. This means the cache will rebuild.
- The cache is often configurable. Even a cache of 5 seconds is pretty effective -- remember that downloading the HTML, JS, and CSS are often requested within the same second. Caching doesn't have to be very long.
Cloudfront is pretty easy to setup and connect to your services.
For Per each GB of egress traffic (traffic from AWS to the internet) you pay $0.085.
Read the Overview and Features of AWS Cloudfront
- Go to Cloudfront in AWS, look at the "Distributions" page
- Create Distribution > Web
- Most can be explained in the Info Icon, right of each field, but add these settings
- Redirect HTTP to HTTPS
- GET, HEAD
- The rest will be defaults
- Side note: In SSL Certificate, you may leave as default, but if you want to add custom domain name, you will need to add DNS settings (read more)
- Try "Default Root Object" as blank, but you may need to add index.html for react, I am unsure.
- prevent/remove HTTP access and make the S3 Bucket private again.