Tuesday, October 25, 2016

http headers - Disabling 206 partial content responses on nginx




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!


Answer



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




Example:



location ~ \.mp4$ {
max_ranges 0;
}

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...