Byte Range Request
HTTP request using the Range header to fetch a specific byte slice of a resource. Essential for video seeking (jump to any timestamp), resumable downloads, and parallel chunk downloads. Returns 206 Partial Content.
Full Explanation
A byte range request says: "I don't want the whole file, just bytes 1000–2000." The server responds with a 206 Partial Content and the requested slice. This is what makes video scrubbing work—when you click to minute 45 of a video, the player calculates the byte offset and requests just that segment.
For CDNs, range request support is critical. Video streaming (the majority of internet bandwidth) relies on it. If a CDN can't handle range requests properly, video players break, downloads can't resume after interruption, and PDF viewers can't load specific pages on demand.
There's a caching subtlety: the CDN should cache the full object and slice it per-request, not cache each byte range separately. Caching individual ranges wastes storage and creates a fragmented cache. Most CDNs handle this correctly, but it's worth verifying with your provider.
Examples
Requesting a specific byte range:
# Request bytes 0-999 (first 1KB)
curl -H "Range: bytes=0-999" -sI https://cdn.example.com/video.mp4
# HTTP/2 206
# Content-Range: bytes 0-999/52428800
# Content-Length: 1000
# Request last 1KB
curl -H "Range: bytes=-1000" -sI https://cdn.example.com/video.mp4
# Resume a failed download from byte 10485760
curl -C 10485760 -o video.mp4 https://cdn.example.com/video.mp4
Nginx enabling range requests for cached content:
# Enable slicing for large files (caches full object, serves ranges)
proxy_cache_path /cache levels=1:2 keys_zone=video:10m max_size=50g;
server {
location /video/ {
slice 1m; # fetch from origin in 1MB slices
proxy_cache video;
proxy_cache_key $uri$slice_range;
proxy_set_header Range $slice_range;
proxy_cache_valid 200 206 24h;
}
}
Frequently Asked Questions
HTTP request using the Range header to fetch a specific byte slice of a resource. Essential for video seeking (jump to any timestamp), resumable downloads, and parallel chunk downloads. Returns 206 Partial Content.
Requesting a specific byte range:
# Request bytes 0-999 (first 1KB)
curl -H "Range: bytes=0-999" -sI https://cdn.example.com/video.mp4
# HTTP/2 206
# Content-Range: bytes 0-999/52428800
# Content-Length: 1000
# Request last 1KB
curl -H "Range: bytes=-1000" -sI https://cdn.example.com/video.mp4
# Resume a failed download from byte 10485760
curl -C 10485760 -o video.mp4 https://cdn.example.com/video.mp4
Nginx enabling range requests for cached content:
# Enable slicing for large files (caches full object, serves ranges)
proxy_cache_path /cache levels=1:2 keys_zone=video:10m max_size=50g;
server {
location /video/ {
slice 1m; # fetch from origin in 1MB slices
proxy_cache video;
proxy_cache_key $uri$slice_range;
proxy_set_header Range $slice_range;
proxy_cache_valid 200 206 24h;
}
}
Related CDN concepts include:
- Content-Encoding — An HTTP response header indicating the compression algorithm applied to the response body. Common values: …