How it works

What happens between typing the address and seeing this page.

1. DNS

Route 53 answers for static-demo.45squared.com with an alias to CloudFront, so your browser connects to the nearest CloudFront edge location.

2. HTTPS

CloudFront presents a certificate from AWS Certificate Manager. It was validated through a DNS record the module created, and it renews by itself. Plain HTTP is redirected to HTTPS.

3. The router

A CloudFront Function runs on every request before the cache. It turns /how-it-works/ into /how-it-works/index.html, sends old addresses to new ones with a 301, and in app mode hands routes like /dashboard to index.html.

4. The cache

If the edge has the file, it answers straight away, compressed. Pages are kept for a day at the edge and cleared on every deploy; images and fonts are kept for 30 days.

5. The bucket

On a cache miss, CloudFront fetches the file from a private S3 bucket, signing the request with origin access control. The bucket blocks all public access, so nobody can go around CloudFront.

What it costs

For a small site, about a dollar a month: $0.50 for the Route 53 hosted zone, a few cents of S3 storage, and CloudFront inside its always-free tier of 1 TB and 10 million requests a month.

Get the module