VideoBB
Upload Premium Sign in

CDN for video delivery

Video is the most cache-friendly traffic on the internet and the most punishing when caching fails. How content delivery networks serve segments, what to cache for how long, and where the costs hide.

A CDN keeps copies of video segments and playlists on servers close to viewers. Most requests then never reach the origin server. Segments are static files with unique URLs, so they cache almost perfectly. Live playlists need short cache lifetimes, and private videos use signed URLs.

Abstract illustration of a network of glowing nodes spread across a curved surface, with copies of a small tile stored at each node

The distance between a server on one continent and a viewer on another is measured in milliseconds. On video, it shows up as seconds of buffering. Every segment fetch is a round trip. A player that waits 200 milliseconds for each of several segments before it starts has already tested the viewer's patience. Content delivery networks shorten that distance. They keep copies of the segments in hundreds of locations.

This explainer covers what a CDN does for segmented video. It shows why the format caches so well and why playlists and segments need different rules. It explains how live and on-demand differ. It also covers the tools that decide whether delivery is fast and cheap: origin shields, signed URLs and HTTP/3. It applies to a self-hosted HLS package and to the segments the VideoBB player fetches when you embed a video. The video streaming hub covers the steps that come before delivery.

Why segmented video caches so well

A CDN cache works by URL. A request arrives at an edge server. If that server holds a fresh copy of the object at that URL, it responds at once. If not, it fetches the object from the origin, or from a larger cache in between, stores it and responds. Segmented streaming, as described in the HLS guide, produces exactly the kind of object caches love: small, immutable files with unique names, requested by many viewers in roughly the same order.

The arithmetic is simple. A popular video at 1080p might be five thousand segments across all renditions. Each is fetched from the origin once per edge location. After that, every viewer near that location is served from cache. The origin sees a trickle, the edges see the flood, and the flood is what CDNs are built for. A monolithic MP4 served with byte-range requests caches far less predictably, because different players request different ranges.

What to cache, and for how long

Cache lifetimes are set with Cache-Control headers from the origin. These are typical patterns, not fixed rules.

ObjectOn-demandLiveWhy
Media segments (.ts, .m4s)Very long; effectively immutableLong; they never change once writtenUnique URLs, never rewritten
Initialisation segment (init.mp4)Very longLongSame across the whole stream
Media playlist (.m3u8)LongSeconds; around half the target durationLive playlists change every segment
Multivariant playlistLongMinutesRarely changes; renditions are fixed
Encryption keysShort or no-store, per policyShort or no-storeAccess control, not performance
Thumbnails and scrub previewsVery longNot applicableStatic images with versioned URLs

Live streams: the same objects, a harder timeline

For on-demand video the CDN can treat everything as static, and a cold cache simply warms as the first viewers arrive. Live changes the timing. Every viewer wants the newest segment within seconds of it being written, so thousands of requests for the same URL hit the edge before it has a copy. A well-designed CDN collapses those into one origin fetch (request coalescing) and holds the others until the object arrives, rather than forwarding each to the origin.

The live playlist is the other pressure point. It is small, changes every few seconds, and is polled by every viewer. Setting its cache lifetime to a fraction of the segment duration keeps viewers close to the live edge without sending every poll to the origin. Low-latency modes, described in the HLS vs DASH comparison, push further with partial segments and blocking requests, and need CDN support for them specifically.

How a segment request travels

  1. The player resolves the segment hostname. The CDN's DNS or anycast routing returns the address of a nearby edge location rather than the origin.
  2. The edge checks its cache for the exact URL, including any query string that forms part of the cache key. A hit is served at once.
  3. On a miss, the edge asks an origin shield. This is a regional cache placed between the edges and the origin, so one region's many edges make one upstream request, not many.
  4. On a shield miss, the shield fetches from the origin, stores the object with the origin's Cache-Control lifetime and passes it back down to the edge.
  5. The edge stores it and serves it. Every later request for that URL from that region is a cache hit until the lifetime expires or the object is evicted.

Access control without breaking the cache

Caching and privacy pull in opposite directions. A private video must not be served to anyone who guesses the URL, but per-user checks on every segment would defeat the cache. The standard resolution is a signed URL or signed cookie: the origin issues the player a token, embedded in the URL or a cookie, that encodes an expiry and a signature the edge can verify without contacting the origin. The segment itself is cached once; the check happens at the edge on each request.

Some content must be encrypted at rest and in transit. For that, HLS carries the key URL in the playlist, and the player fetches the key separately. So keys can be protected with the same token method while the encrypted segments stay fully cacheable. On VideoBB the per-video privacy settings (public, unlisted and private) decide who may reach a stream; the help centre explains how each behaves.

Mechanisms that move the needle

Origin shield

A regional cache tier between edges and origin. Cuts origin load from one fetch per edge to one fetch per region and smooths live traffic spikes.

Cost and resilience
HTTP/2 and HTTP/3

Multiplexed connections mean a player can request the next segment without opening a new TCP or TLS handshake; HTTP/3 over QUIC also survives network changes on mobile.

Latency
Cache key normalisation

Stripping irrelevant query parameters so that the same segment requested with different tokens still maps to one cached object.

Hit ratio
Prefetch hints

The player, or the CDN itself, requests the next segment before it is needed, warming the cache ahead of the playhead.

Start-up time

Where the costs hide

  • Egress. CDN pricing is dominated by bytes delivered, and every rendition a viewer watches is bytes delivered. So an efficient encoding ladder, as described in the transcoding guide, is also a cost control.
  • Origin egress. A low cache hit ratio means the origin, often a cloud storage bucket with its own bandwidth pricing, serves far more than it should. Shields and long segment lifetimes are the fix.
  • Small audiences spread thin. A video with ten viewers in ten countries produces ten cold-cache fetches and little benefit from caching at all; this is normal and not a fault.
  • Cache churn. Very short segments multiply object counts; very large libraries can exceed edge storage so that unpopular content is evicted and re-fetched. Neither is dramatic for most sites, but both show up in the origin bill.

Frequently asked questions

Do I need a CDN for a small site with a few videos?

If the videos are hosted on a platform such as VideoBB, delivery is already handled. Your own site only serves the embed code. If you self-host HLS on a single server, a CDN pays off once viewers are far from that server or arrive in bursts. Without one, each viewer pulls every segment across the whole distance. For a handful of local viewers it is optional.

Why does a video sometimes start slowly and then play perfectly?

The first viewer in a region after a quiet spell often hits a cold edge cache. The first few segments travel from the origin or shield before the edge has copies. Later segments, and later viewers, are served from the edge. Players soften this by starting at a lower rendition, as the adaptive bitrate guide explains, then stepping up once throughput settles. If a video still stalls after that, the help page on playback that stutters or will not start lists the checks to run.

Can a CDN cache private or unlisted videos safely?

Yes, with signed URLs or signed cookies. The segment is cached once like any other object, but each request carries a short-lived token that the edge verifies before serving. Someone who obtains a segment URL without a valid token is refused. Encryption keys can be protected the same way, so the encrypted segments themselves remain fully cacheable.

Does HTTP/3 make video delivery faster?

It removes some of the overhead. QUIC combines transport and TLS handshakes, avoids head-of-line blocking between multiplexed requests and keeps a connection alive when a phone changes networks, all of which help segment fetches on mobile. The gains are largest on lossy links and small on a good wired connection; it is worth having but does not replace good caching.

Sources

cdnvideo deliveryedge cachingorigin shieldstreaming

Related guides