In general most web applications uses the local file system or Network Attached Storage (NAS) as the asset storage. Here is an example of a website using local file storage to host the assets.
List of HTTP requests from users browser to server
The above approach works and there is nothing wrong about it, but this is not optimal.
Here is why — Consider a situation domain.com is a high traffic website. Higher the traffic the more is going to cost as you will need to scale up the servers to meet the demand. What if we move the assets to an external CDN? as per above example out of those 5 HTTP requests only 1 request will reach the nginx server — and all the other assets will be served from external CDN, saving the bandwidth, computing resources like CPU, RAM on the primary web server(s).
Another example is — If your apps are deployed on a load balanced environment with multiple web server instances, you will need to keep each instance up to date with static contents and things will be even messy with dynamic contents as you need to either copy the assets to all the nodes or use a shared storage. But with a CDN in place you will need to copy them into one place — your CDN.
That’s some theory inedeed — In my next post on CDN I’ll try and compare these two approaches and see if this really works — in terms of improved performances as well as cost savings.