I didn't use a cdn myself but I'm really curious on how data gets uploaded to them. Suppose a user uploads an image to a cdn pop, is that image stored only on that one cdn pop? But if so if user moves away and uses another cdn pop the image will not be availble?
Or what if another user wants that image but that cdn pop is far away from her/him?
Otherwise the image needs to be uploaded on hundreds of cdn pops, which takes lot of bandwidth. Thus an image of 10kb could take tens of megabytes of your available bandwidth/month.
This doesn't make lots of sense to me.
Can anybody clear this up ?
解决方案
There are two ways you can serve data from most CDNs:
Using a pull zone: This pulls existing content from your origin server and caches it on the CDN's PoPs
Using a push zone: You manually upload content to the CDNs storage cluster and from there the content gets distributed to the CDN's PoPs.
To answer your other questions:
Asset caching is based on where the visitor is requesting the asset from. If the visitor is in Australia and the CDN has a PoP in Australia then the asset will be cached there. However, if another user requests the same as from Germany, and the CDN has a server in Germany then the asset will be cached there as well.
The asset will always be delivered from the nearest available PoP. If the PoP doesn't have the requested asset, it will ask the server and then cache the asset so that it can be delivered faster to the next requester.
To learn more about how CDNs work and what they entail, I'd recommend taking a read through this guide: https://www.keycdn.com/what-is-a-cdn