CDNs, Assets and Caching

What is a CDN?

A Content Delivery Network (CDN) is a network of geographically distributed servers that work together to deliver web content, like images, videos, stylesheets, scripts, and other assets, to users based on their geographic location. CDNs are designed to improve the performance, reliability, and availability of online content by reducing the distance between users and the servers hosting the content.

What are the benefits?

Some of benefits of using a CDN to handle assets include:

  1. Distribution: Images are stored on a variety of servers globally (called edge servers). When a user wants an image, the nearest server provides it, reducing delays.
  2. Caching: Frequent images are stored temporarily in a cache on edge servers. When a user requests an image, the cache is checked first, avoiding the need to fetch it from the main server.
  3. Cache Control: Rules dictate how long images stay cached. After a set time, the image is refreshed from the main server.
  4. Hierarchy: CDNs have layers of caches, with the closest server to the user caching images while others are cached closer to the main server.
  5. Dynamic Optimization: Some CDNs adjust image properties like size and format based on user devices and networks, ensuring optimal delivery.

Further Reading: