2 ms·
IMHO the most useful features have is the ability to "pin" items to the browser cache for offline usage. Of course this could have just been added to a response
by kevincox 6y ago
IMHO the most useful features have is the ability to "pin" items to the browser cache for offline usage. Of course this could have just been added to a response header or something but there are a number of flexibility provided with service workers which is arguably useful.
One nice feature is purging no-longer needed cache entries for an old version of the site (Example old JS and CSS). Of course there is no reason this couldn't be done in the page context itself.
The other feature that service workers are for is receiving push notifications. Although they don't need to be in the way of HTTP requests for that.
So they really just allow adopting features faster then HTTP caching is updating by browsers. However they are a huge footgun if you ship a broken service worker. (You need to wait >24h for all of your users to update to a fixed version).
Unfortunately if you want to be eligible for "Add to homescreen" you need one, which is a shame because this is just for offline support, which would be easy to add with a cache header.
Firefox Requirements: https://web.dev/install-criteria/#criteria https://web.dev/install-criteria/#criteria
Chrome Requirements: https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Add_to_home_screen#how_do_you_make_an_app_a2hs-ready https://developer.mozilla.org/en-US/docs/Web/Progressive_web...