Disabling 206 partial content responses on nginx

JuCachalot asked:

I have an HTML5 web app that uses a video tag. Depending on the user actions, different parts of the video will be played in response. This video does not exceed 5MB.

I need this video to be entirely downloaded on the client otherwise the user will have to wait for buffering if the part to be played is at the end of the video. Indeed, browsers behavior is to ask if Range Request are supported and to get a HTTP 206 partial content response from my server nginx.

I found a way to do what I want using xhr2 to download the entire video as a BLOB. However, I was wondering if it would be possible, for browsers which do not support xhr2, to make nginx refused Range Request and to send a classic HTTP 200 response so that the browser will fetch the entire video.

Is that possible? Thank you very much for your help!

My answer:


Set max_ranges to 0. This requires nginx 1.1.2 or higher.

Example:

location ~ .mp4$ {
    max_ranges 0;
}

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.