linux - Nginx做视频缓存,怎样边回源边响应给用户
大家讲道理
大家讲道理 2017-04-17 14:54:16
0
1
782

用Nginx的proxy功能,在客户请求一个70mb的文件时,Nginx用1mb/s的速度去视频网站下载这个mp4文件,客户那里一直黑屏,直到70s后,Nginx以8mb/s的速度将完整的mp4文件传给了用户,视频才播放起来。 这样做的话,面对一个未缓存的新视频,第一个访问的用户要等70s才能看,有点麻烦。请问有什么好的解决方案吗?目前想的是用爬虫来假装第一个用户,但这样也只是解决了热门视频的问题。 请不吝赐教

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(1)
巴扎黑

proxy_buffering off

nginx turns on proxy_buffering by default. It will try its best to read the responses data and temporarily save it, and then send it to the customer after receiving it.
After proxy_buffering is turned off, nginx will immediately send the obtained mp4 data to the client. After the client collects enough metadata for playback, it can start playing, usually very quickly (if the file itself is not suitable for streaming media playback, it is another problem. It happened, but it’s rare anymore)

SF’s first answer, please correct me if I am wrong.

Reference documentation: http://nginx.org/en/docs/http...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template