直播,从延迟到卡顿

0 序

同学们整了个直播平台。

他们跑起来了!他们用的服务器没有前端!

他们自己写了!他们写挂了!他们来折磨我了!

1 技术栈

他们用的是这玩意 https://github.com/ZLMediaKit/ZLMediaKit。其实我是不开心的,因为这种大而全的东西往往代码都比较离谱,而且文档和沟通记录全中文,怎么看怎么离谱。

不过我不趟这浑水,跑都跑起来了管他干啥。

Continue reading “直播,从延迟到卡顿”

折腾小记 – Service Worker

0 序

退役了,文化课了。于是每天写代码的时间连 20min 都没有了。

但我还是想写!那就整点乐子吧

1 Service Worker

The service worker is designed first to redress this balance by providing a Web Worker context, which can be started by a runtime when navigations are about to occur. This event-driven worker is registered against an origin and a path (or pattern), meaning it can be consulted when navigations occur to that location. Events that correspond to network requests are dispatched to the worker and the responses generated by the worker may override default network stack behavior. This puts the service worker, conceptually, between the network and a document renderer, allowing the service worker to provide content for documents, even while offline.

https://www.w3.org/TR/service-workers/#motivations

翻译一下就是

Service Worker 提供了一种在请求前进行处理的 Web Worker。开发者可以通过此技术来拦截并修改每一个请求,并通过访问缓存等方式实现在网络较差甚至离线情况下对网页的访问。

Continue reading “折腾小记 – Service Worker”