Service Worker for HLS video prefetching
node build.js # Concatenates src/ → sw.js
# Chrome: http://localhost:3001/webtest/
node test_offline_startup.js
- Progressive playlist parsing - Start playback before full manifest loads
- Lookahead prefetch - Preload segments ahead of playback position
- Multi-tier cache - Memory → Disk (Cache API) with quota enforcement
- Stall detection + range requests - Switch to parallel range fetches on slow downloads
- Recovery/cooldown - Retry with backoff, host/segment cooldown
| Type |
Purpose |
LINE_CHANGE |
Reset state, send INITIAL to client |
PREPARE_START |
Parse manifest, prefetch target + lookahead |
TIMELINE_JUMP |
Set seek target time |
PLAYER_STATE |
isPaused, seeked |
PLAYBACK_POSITION_UPDATE |
Periodic position for adaptive prefetch |
| Type |
Purpose |
INITIAL |
Client should re-initialize |
PREPARE_PROGRESS |
Preparation progress % |
PREPARE_START_READY |
Target segment ready |