Why should the browser make two separate requests for the same file?

I am debugging a program that I wrote, and noticed something strange. I set up an HTTP server on port 12345, which serves a simple OGG video file and tries to access it from Firefox.

After listening to network requests, I found that these two requests were made:

GET /video.ogv HTTP/1.1 Host: 127.0.0.1:12345 User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive GET /video.ogv HTTP/1.1 Host: 127.0.0.1:12345 User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Range: bytes=8122368- 

The video is almost 8 MB in size, so the fact that the second request contains 8122368 bytes, which is 7932 KB, suggests that for some reason it asks for the very end of the file. Does anyone have any idea?

+7
firefox networking network-programming
source share
3 answers

To support the search and playback of media areas that are not yet loaded, Gecko uses HTTP bytes with HTTP 1.1 bytes to retrieve media from the target search position. Since Ogg files do not contain their duration, the original download connection is terminated. Then it searches for the end of the Ogg file and reads a data bit to extract the time duration of the medium. Information from here and here .

+8
source share

Some media formats have metadata at the end of a file, and this data is usually required to properly search for videos.

+2
source share

In fact, it requests 8122368 bytes, starting from the end. This is 7.74 MB if I performed my calculations correctly.

it may be something in how buffering is done for this type of file.

0
source share

All Articles