Menu

I shipped a 0.91 MB PWA that refuses to serve stale code: the service worker setup behind RKMovies
📰

I shipped a 0.91 MB PWA that refuses to serve stale code: the service worker setup behind RKMovies

DEV Community: android·hammi·13 days ago
#ykbREJyV
#devtoandroid#devto#dev#shell#cache
Reading 0:00
15s threshold

Disclosure: I built RKMovies, a small 4K media player client for Android and Windows. This post is a build diary of its web shell.

Most PWA advice ends at "cache everything". That breaks the moment you ship an update, because users keep running old JS against new HTML. For a media player that is not cosmetic. It is broken playback.

So the shell of this offline-first PWA goes network-first, with one hard rule: code assets are only ever served from an exact URL match.

The install handler precaches the shell with versioned URLs:

const CACHE = " rkmovies-shell-v43 " ; const SHELL = [ " / " , " /index.html " , " /style.css?v=135 " , " /adgate.js?v=74 " , " /updater.js?v=71 " , " /app.js?v=157 " , " /vendor/artplayer.js?v=59 " , " /manifest.webmanifest " ];

Enter fullscreen mode

Exit fullscreen mode

The fetch handler passes every /api/ and /proxy request straight to the network (never cache those), and for same-origin GETs it tries the network first.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.