What Are HTTP Range Requests?

How HTTP Range Requests work and allow for precise data transfers (and pausing/resuming of downloads).

HTTP Range Requests

Introduction

HTTP is the set of rules that govern how content is served on the World Wide Web. In order to get content from a website, your browser needs to make HTTP requests to the web server hosting the website, and the server responds by serving the requested content.

Typically, the web browser serves the entire file that a browser has requested. However, this isn't always practical. For example, if you're streaming an episode of a web series, you might skip the intro credits.

Using the conventional way of serving files, you wouldn't be able to skip that first few minutes. You'd first need to download the entire file, which could take quite a while depending on the file size, the speed of your internet connection, and the speed of the server's connection. Only after you finished downloading the entire video would you be able to jump to other parts of the video.

HTTP range requests resolve these problems by issuing byte-range requests.

What are byte-range requests?

Byte-range requests don't ask the web server to serve an entire file. Instead, it requests the server to only serve a specified portion of the file. For example, let’s assume that the video you want to stream contains a total of 10,000 bytes, and you only want to watch the last few seconds. Instead of requesting the server to send the entire file from the first byte to the 10,000th byte, your browser could make a byte-range request asking the web server to transfer from the 9,000th byte to the 10,000th byte.

The HTTP request header sent by your browser includes a line that looks something like this:

Range: bytes=9000-10000

Byte-range requests can also be broken into multiple different parts called multi-part ranges in the HTTP request header, which look something like this:

Range: bytes=0-499, 500-999, 1000-1499

In this request, instead of requesting for the entire range from 0-1,499, the byte-range request is divided into three parts to get the same data from the web server.

Benefits of byte-range requests

If you just want to watch a portion of a video on a website, it is really a waste of bandwidth to have to download the whole video file, especially if you are using cellular data plans with a monthly cap. From the web server’s perspective, it is also a waste of their bandwidth to serve you an entire hour-long video when all you need is just a minute of it.

In addition, multipart byte-range requests offer other benefits. Splitting the request of a large byte range into a series of smaller byte ranges isolates transmission errors, meaning they only affect the part of the download where they happen. If the range isn't split into parts, the entire range would have to be re-downloaded.

What Are HTTP Range and Byte-Range Requests?

Also, by using multipart byte-range requests, file downloads can be paused and resumed. The browser can simply request from the web server only the remaining parts starting from the range where the download was stopped earlier. Multi-part range requests can also speed up downloads by allowing the web server to serve different smaller byte-range parts in parallel, instead of sequentially serving the bytes specified in a single large byte range.

Did you find this article helpful?

0 out of 0 Bunnies found this article helpful

Glossary

HTTP

Hypertext Transfer Protocol. A protocol that connects web browsers to web servers when they request content.

Prove your Knowledge.
Earn a bunny diploma.

Test your knowledge in our Junior and Master Quizes to see where you stand. Prove your mastery by getting A+ and recieving a diploma.

Start the QuizBunny with a diploma.