CloudFront is Amazon Web Services’ Content Delivery Network (CDN).
A CDN delivers your website's files (images, videos, CSS, JS, PDFs, etc.) to users from the server nearest to them, instead of always serving them from your main server (e.g., S3 bucket or EC2 instance).
CloudFront exists to make websites load faster for users all around the world.
Imagine:
When someone from USA opens your web app, the data has to travel:
USA --> Singapore (S3 bucket)
This distance causes slow loading (high latency).
CloudFront acts like a network of mini storage places around the world.
Instead of everyone getting files from ONE place (your main server),
CloudFront puts a copy of your website files (images, videos, CSS, JS) into the server closest to the user.
| User Location | CloudFront Edge Location |
|---|---|
| Kathmandu (Nepal) | Mumbai Edge Location |
| New York (USA) | Virginia Edge Location |
| Germany | Frankfurt Edge Location |
Now, a user from USA gets the files from USA server, not from Singapore.
→ This makes loading extremely FAST.
We need CloudFront so that our website files (images, videos, CSS/JS) load very fast for users anywhere in the world by caching data near them.