bootstrapping-microservices/chapter-5

When I visit 'http://localhost:4001/video', it will emerge 2 records in Mongodb (video)

Closed this issue · 1 comments

When I enter "http://localhost:4001/video" in my chrome,I find this:

image

image

The first request's type is document, the second is media, but both of them are same url.
I guess the twice requests lead to this result.But I don't know why it produces twice different type request.

Note: I was curious to find the reason, until I saw the console output:

image

I think it's because a browser will usually probe for streaming video using HTTP HEAD request followed by a HTTP GET request which are both handled by the HTTP GET request handler in Express, so it can look like the request is coming through twice.

I actually have a blog post up for more advanced video streaming:

https://www.the-data-wrangler.com/video-streaming-in-safari

That's necessary for Safari, but it can also help with video streaming for other browser's like Chrome.

Hope that helps!