
Service Workers - kiyanwang
https://hackernoon.com/service-workers-62a7b14aa63a
======
aclatuts
I think service workers are the biggest foot gun to web development. There are
so many issues you bring to the table just to have offline capability.

First you have to design a service worker that can intelligently download new
updates to your app, relay to the user there is a new version, and you have to
make sure you support changing apis as clients can be using the old versions
of an app for a long time.

You have to design self destruct logic because your service worker itself can
have bugs and break your app. In addition your self destruct logic can break.

You also have to make sure you service worker does not infinitely cache an old
version of you app, because it will never expire without correct logic. You
cant just assume to download higher version numbers, some times you want to
revert to an older version of your app.

~~~
k__
Can't you just add a dead mans switch?

~~~
dfabulich
Sure, that's a kind of "self destruct logic," as aclatuts put it. Just make
sure you coded and tested _that_ correctly...

------
nbar1
Unfortunately, until Apple gets onboard we aren't willing to take advantage of
them at my job.

~~~
CharlesW
Apple came aboard with iOS 11.3.[1][2]

[1] [https://webkit.org/blog/8090/workers-at-your-
service/](https://webkit.org/blog/8090/workers-at-your-service/) [2]
[https://caniuse.com/#feat=serviceworkers](https://caniuse.com/#feat=serviceworkers)

~~~
hokumguru
Ok but for real their implementation is _severely_ lacking.

~~~
merpnderp
They are doing everything they can to put off Safari Push on iOS. That will
seriously destabilize the App Store, by giving webapps the most important
feature of native apps, Push.

------
mLuby
I hate to say it, but the writing is strange; Hacker Noon should have someone
proofread it.

~~~
webXL
There's also a syntax error in the first code sample:

[https://gist.github.com/ankita1910/1ff6c67a63c0f2d62a5c82c7d...](https://gist.github.com/ankita1910/1ff6c67a63c0f2d62a5c82c7d8dcb3e3#file-
fetch-js-L12)

------
news_to_me
Do service workers work with iOS yet? Last time I tried doing the "progressive
web app" thing, apple was on an older, shittier iteration of the idea.

~~~
laen
Apple has started to implement service workers in the latest Safari, but it
still lacks behind the other browsers - I suspect they are worried it will
provide a disincentive for applications to be hosted on the app store.

My biggest draw to PWAs was the ease of which I could deploy an intranet app
on portable devices with spotty connectivity. This works fine with the
appcache, which is what I currently use, but service workers require SSL and
self-signed certificates are a no-go. This adds to the complexity of using
service workers in a simple intranet hosted PWA. Also, back to Safari's poor
implementation of service workers, the amount of time a PWA will reside in the
browser is unspecified. I can only imagine the the headaches it will cause if
the PWA drops randomly. So I'm avoiding service workers in my PWAs for now.

When appcache deprecates (it's slated to), maybe it will be time for me to go
native if I am going to have to add complexity regardless.

------
CoolGuySteve
> immediately switched back to my browser to navigate to the website, to read
> the blog that I was peacefully reading on the native app

I had to read this twice because I couldn't believe there's actually someone
out there who prefers those "install the app" banner spam apps that the mobile
web is littered with.

------
SteveParker60
Unclosable pop-up. Again.

~~~
cryptonerd2212
Slightly related - not much a fan of hackernoon. The electric lime green
banner at the top is essentially blinding. I had to zap the element with
Ublock Origin just to read the article comfortably.

------
dekhn
I tried service workers and even just unlaunching the feature was a major
challenge. Our users ended up having cached versions of the site with a
service worker for every and we had to put a ton of cache busters in to deal
with it.

Not ready for primetime.

~~~
lazysheepherd
Sorry but it is completely your own fault. We've been using Service Workers on
production for two years now, and never had any issues of any sorts. Also
kudos for "trying" a new API on production.

~~~
alluro2
Person 1: "It didn't work for my single use case / environment / circumstances
= non-working garbage"

Person 2: "It worked for my single use case / environment / circumstances =
the best thing ever, it's your fault"

:)

------
millstone
The design of service workers is ridiculous!

A normal application will check if a file it needs is downloaded, and if not,
download it.

An insane application would unconditionally attempt to download the file,
except first it forks off a new child process, turns it into a network MITM
proxy, and have it intercept the request. Because how else can you access
local files on disk except through HTTP?

