Writing a Mini-CDN to Learn Nginx/Prometheus/Grafana/Lua
The hard part of building a CDN is to know when you need it. 99.9% of all websites with CDN do not need it.
Serving static files consumes so little resources that a single server can serve billions of users as long as you dont use script for serving the file. The most cost-effective with also the lowest latency solution is to never use CDN. If your webserver provider charge you a lot for traffic you are better off using another provider.