Skip to content
Range Requests & Partial Content
step 1/5

Reading — step 1 of 5

Read

~1 min readCaching, Compression & Beyond

Range Requests

Big files (videos, ISO images, model weights) shouldn't have to be re-downloaded end-to-end when a network blip drops the connection. HTTP/1.1 Range requests let a client ask for a specific byte slice — the foundation of resumable downloads, video seek, BitTorrent-over-HTTP, and HTTP/2 streaming.

Wire format

GET /video.mp4 HTTP/1.1
Range: bytes=0-1023        # first 1024 bytes
Range: bytes=1024-          # from byte 1024 to end
Range: bytes=-500           # the LAST 500 bytes (suffix range)
Range: bytes=0-499,1000-1499  # multipart range (rare; mostly PDF readers)

Server response

Status 206 Partial Content, with:

HTTP/1.1 206 Partial Content
Content-Range: bytes 0-1023/45678   # which bytes / total size
Content-Length: 1024                 # length of THIS slice
Accept-Ranges: bytes
...1024 bytes of body...

Errors

  • 416 Range Not Satisfiable — range start beyond file size, or unparseable
  • The response must include Content-Range: bytes */<total> so the client knows the actual size.

Server signaling

Accept-Ranges: bytes        # we support byte ranges
Accept-Ranges: none         # we don't (clients won't try)

Edge cases to test: suffix ranges (-500), start-only (1024-), inclusive end byte (0-1023 means 1024 bytes), and out-of-range starts.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…