Lesson 4 of 16
26. CDNs

26.3 Pull vs push CDN: what's the difference?

3 min read+10 XP

In the warehouse: Some warehouses restock on demand: a shop asks for a product, and if the shelf is empty, the warehouse orders it from the factory and keeps some on hand. Others are stocked in advance: the factory ships the full range to every warehouse before launch day.

In the system:

pull CDNs fetch from the origin on a miss; push CDNs serve files you uploaded in advance.

Figure: pull is easy and caches what's popular; push avoids cold misses but you manage the files.

  • Pull CDN (the common choice): you point the CDN at your origin. On a miss, the edge fetches the file from the origin, caches it according to its headers, and serves it. Zero upload work, and only popular files take up space. The first request per PoP is slower.
  • Push CDN: you upload files to the CDN's storage when you publish them (often object storage like S3 behind the CDN, Chapter 11). Requests are served from there, so the origin isn't involved at all. No cold misses from the origin, but you manage uploads, versions and deletions.

In practice many setups are a mix: static assets and covers sit in object storage that the CDN pulls from, and big launches can be pre-warmed by requesting key files through the CDN before the traffic arrives.

Memory code: "Restock when asked, or ship before launch day."