# CDN push and pull

> Put copies of your content on servers near users, either filling them on demand from your origin (pull) or uploading them yourself (push).

A CDN keeps copies of your responses at the edge, and pull and push differ in who puts them there.

## Use it when

- Most traffic is pages, images, or video that many users share.
- Users are far from your origin, and the round trip dominates latency.
- Egress from your servers is a large part of the bill.

## How it works

With pull, the first request for a file misses, the edge fetches it from your origin, stores it for the TTL, and serves the next visitors itself. You do nothing to publish. With push, you upload files to the CDN yourself, which suits large files that change rarely, such as installers or video segments.

The cache key decides what counts as the same file. A key of path alone shares one copy among everyone and has the best hit ratio. A key that includes cookies keeps personal pages apart. A TTL of an hour raises hits and also lets old pages live for an hour, which is why deploys purge the cache.

## What it costs

A key that leaves out the cookie can show one user's page to another, and a long TTL without a purge serves yesterday's release. Pull also makes the first visitor to each file slow, and a purge sends a wave of misses back to the origin.

## In Quorum

Place a [CDN](https://wiki.playquorum.dev/components/cdn.md) after [Content delivery](https://wiki.playquorum.dev/research/cdn.md) and link it in front of the App Server. The game models pull only, so push is out of scope. Purge on deploy is the nearest control: a deploy empties the edge, and it refills from the origin.



The [Cached page leak](https://wiki.playquorum.dev/incidents/page-leak.md) incident is the cache key mistake, and [Edge-side includes](https://wiki.playquorum.dev/research/esi.md) is what makes a logged-in page cacheable at all. The glossary defines [CDN](https://wiki.playquorum.dev/glossary/cdn-content-delivery-network.md).

Source: https://wiki.playquorum.dev/patterns/cdn-push-and-pull
