Video and large file delivery

Range requests and seeking, segment-based streaming, adaptive bitrate basics, how large files are cached and evicted, and controlling bandwidth cost.

Range requests

# the client asks for a byte range
curl -sI -H "Range: bytes=0-1023" https://cdn.example.com/v/talk.mp4 \
  | grep -iE "content-range|accept-ranges|content-length|age"

# a 206 response means the range was honoured
# a 200 with the full length means the server ignored the range
  • A player opens a file by requesting the last bytes first, to read the metadata at the end. If ranges are not supported, the whole file is downloaded before playback.
  • The origin must send Accept-Ranges: bytes and return 206. A proxy that strips range headers breaks seeking in a way that looks like a player bug.
  • Range requests are separate cache objects on some platforms, so a video watched in ten seeks can be billed as ten requests. Check how the provider counts them.
Response headers for a seekable, cacheable file

  Accept-Ranges: bytes
  Content-Length: 52428800
  Cache-Control: public, max-age=31536000, immutable
  Content-Type: video/mp4

The filename should contain a hash. A 50 MB file with a stable URL cannot be
cached for a year, because you can never change it.

Segmented streaming

FormatPlaylistSegmentsUse it for
HLS.m3u8Small .ts or .m4s filesBroad compatibility including Apple devices
MPEG-DASH.mpdSmall segmentsDevices and browsers that support it
Progressive MP4moov atom at the frontOne file with rangesShort clips and simple embed cases
WebMSingle file with rangesOne fileOpen formats with limited device support
Adaptive bitrate in one paragraph

  The video is encoded several times at different resolutions and bitrates and
  cut into short segments of two to six seconds. The playlist lists the renditions.
  The player measures throughput and buffer level and switches rendition between
  segments, so a slow connection drops to a lower quality instead of stalling.

  Cache consequences
    many small segment files, all immutable and cacheable forever
    playlists that change and need a short lifetime
    the cost is dominated by request count, not by file size
  • Segment files are ideal cache objects: immutable, small and requested exactly once by most viewers.
  • Playlists must not be cached for long. A stale playlist sends the player to segments that no longer exist.
  • Encode for the middle of your audience, not for the best connection. A 4K rendition that nobody can stream is bandwidth you pay for on every upload.

Controlling cost

  1. Measure the cost per hour of video watched, not per file. It is the only number that predicts the bill.
  2. Serve segments from the edge and never from the origin. A video that misses the cache is the most expensive request on the site.
  3. Consider whether every viewer needs the highest rendition. Removing the top rendition from the ladder usually saves more than any encoding tweak.
  4. Use a signed URL or a signed cookie for paid content so a copied link does not become free bandwidth.
  5. Delete or archive old video. Storage for a library nobody watches is a line item that grows and never shrinks.
  6. Cap the request count per viewer per minute at the edge. A misbehaving player that fights for segments can generate enormous request volume.
Cost driverTypical shapeLever
Egress GBDominant for videoLower bitrates, shorter content, regional delivery
Request countLarge because of segmentsLonger segments, cheaper request tier
TranscodingOne-off but significantFewer renditions, hardware encoding
StorageGrows with the libraryLifecycle rules, deletion
Live deliveryPriced differently from VODOne rendition when quality is not critical
💡
Video is the workload where CDN economics are least forgiving. Before optimising anything else, check the request count and the egress separately for the video path - one is usually an order of magnitude larger than expected, and the fix is different in each case.

FAQ

Do I need a streaming service or just a CDN?
For a few short clips, a CDN plus progressive MP4 is enough. For anything long-form, adaptive bitrate or live, a streaming platform handles the encoding, packaging and playlists that you would otherwise build yourself.
Why does my video start slowly?
The metadata is at the end of the file and ranges are not supported, so the player downloads everything first. Move the metadata to the front or serve it as segments.

Image CDNs and on-the-fly transformation Signed URLs, token authentication and hotlink protection

Last refreshed 2026-09-18.