We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Streaming

Now that (almost) no one is on dial-up 256k modems, we typically don't worry about "streaming" smaller files like images.

But giant audio files (like audio books), and especially large video files should be streamed rather than downloaded. At least if you want your user to be able to start consuming the content immediately.

Click to play video

Streaming vs. Downloading

  • Downloading is when you wait for the entire file to be transferred before you can start using it.
  • Streaming is when you start using the file immediately while it's still being transferred in the background.

The simplest way to stream a video file on the web (imo) is to take advantage of two things:

  1. The native HTML5 <video> element. It streams video files by default as long as the server supports it.
  2. The Range HTTP header. It allows the client to request specific byte ranges of a file, enabling partial downloads. S3 servers support it by default.

Writing streaming from scratch is hard, but using the right tools makes it pretty easy these days.

Assignment

For this next part, Chrome or Firefox will work - I'm not sure about other browsers. Additionally, your numbers might be a bit different than mine, but should be in the same ballpark.

A 206 status code means "Partial Content" - that's because the browser is smart enough to realize that it should not download the entire 100MB+ video before starting to play it. It's downloading just enough to start playing the MP4 file.

Answer the question.