# Static files on object storage and a CDN

> Serve pages and media from the edge and keep files in Object Storage, so the origin only handles what must be fresh.

Put a CDN in front of the origin and keep uploaded files in Object Storage.

## Move up when

- Page views and video take most of the App Server's CPU and the egress line is large.
- Every user in the world waits for a round trip to one origin.

## The Design





In the first picture every page view reaches the App Server. In the second, Users reach the CDN first. It answers what it has cached and sends misses and every other request kind to the origin.

## Why it works

The CDN's hit ratio is the share of page views it answers without touching your servers. The App Server and Database load bars fall, and p99 falls with them because the hit is answered near the user.

Two settings matter. A long TTL raises the hit ratio, and purge on deploy empties the edge when you release so no one sees old pages. A cache key with less in it raises hits further but can leak one user's page to another.

## What it costs

The CDN does not cache API reads, writes, logins or checkouts. A long TTL without a purge serves stale pages after a deploy. A purge makes the origin take a burst of misses while the edge refills. Object Storage reads wait longer for the first byte than a Database query.

## In Quorum

Research [Content delivery](https://wiki.playquorum.dev/research/cdn.md) for the [CDN](https://wiki.playquorum.dev/components/cdn.md) and [Object storage](https://wiki.playquorum.dev/research/object-storage.md) for [Object Storage](https://wiki.playquorum.dev/components/storage.md). The glossary defines a [CDN](https://wiki.playquorum.dev/glossary/cdn-content-delivery-network.md) and [egress](https://wiki.playquorum.dev/glossary/egress.md). [CDN push and pull](https://wiki.playquorum.dev/patterns/cdn-push-and-pull.md) covers the pattern. The next rung is to [add a cache](https://wiki.playquorum.dev/patterns/add-a-cache.md).

Source: https://wiki.playquorum.dev/patterns/static-files-on-object-storage-and-a-cdn
