Live data from Hacker News

Writing a Service Worker

hacklabo.com

31–40 of 60 posts

Re: Writing a Service Worker

#31
post #11
post #3

Best use case of this I guess, is some kind of flight mode for web apps. Before going in to metro or flight, you click a button, and for example HN caches front page for you.

Caching cross-origin resources is problematic because you can't check the response code: https://stackoverflow.com/q/35626269

[deleted]

Re: Writing a Service Worker

#32

I always get all stoked on service workers until I remember that half my users are on safari. Then I get bummed.

> I always get all stoked about creating an iOS app until I remember that half my users are on android. Then I get bummed.

But seriously it is a bummer Safari doesn't support service workers yet. It's possible higher adoption would put more pressure on Apple to add support. In the meantime it can be a great enhancement where it is supported.

Re: Writing a Service Worker

#33
post #24

What borders me, is that you need an valid SSL cert for an service worker, however there is a develop/test cert here: https://github.com/Eun/test.bi

I don't get it, how is one supposed to use that, if the domains point to your IP addresses?

Re: Writing a Service Worker

#34
What does the "Got it!" button do? Just let the author know that I understood the guide?

I really like that button. I don't know, it just drives home the point that you care that I understood your guide -- which was clear and easy to read.

Re: Writing a Service Worker

#35
post #22

I always get all stoked on service workers until I remember that half my users are on safari. Then I get bummed.

What's the difference with Safari? (not a JS dev, so this is not familiar territory)

It's not just a safari problem, last I checked Chrome on iOS also does not support service workers, so you're just helping Android users.

Apple has a vested interest in pushing users towards their walled garden for apps, while Google and Mozilla are trying to bring app-like experiences to the browser. There are hints of Safari supporting serviceworkers but I'm not holding my breath.

Highly recommend Alex Russel's talk on progressive web apps as background: https://m.youtube.com/watch?v=x7cfLDFVyHo

I happen to agree that offline-readiness (via service workers) is at the core of whether the open web will continue to be a relevant medium.

Re: Writing a Service Worker

#36

What does the "Got it!" button do? Just let the author know that I understood the guide? I really like that button. I don't know, it just drives home the point that you care that I understood your guide -- which was clear and easy to read.

Isn't that button for acknowledging the fact that the site will use cookies?

Re: Writing a Service Worker

#37

I was going to say, "Isn't this what the application cache is for?" then I looked and saw it has been removed from the standards.

AppCache looks like a poor hack if you want offline site that is more complex than just a static blog post. There are numerous edge cases that you can easily handle in SW's JavaScript vs AppCache's limited declarative language. For example navigation requests can be special cased. Or you can decide yourself when to make a network request vs cache lookup. AppCache used some weird rules (e.g requests with query parameters never use cache).

Re: Writing a Service Worker

#38
post #13
post #3

Best use case of this I guess, is some kind of flight mode for web apps. Before going in to metro or flight, you click a button, and for example HN caches front page for you.

More than that - service workers have background sync and stuff like that as well. Imagine a messaging app where you can read and write messages no matter what the connectivity state is, then have the phone sync when you come back online.

Exactly. I've written something like that but instead of messaging it was an issue tracker meets wiki. Completely offline with SW and IndexedDB with background sync when there was a connection. Works very well on the airplane :)

Re: Writing a Service Worker

#39

What does the "Got it!" button do? Just let the author know that I understood the guide? I really like that button. I don't know, it just drives home the point that you care that I understood your guide -- which was clear and easy to read.

Isn't that button for acknowledging the fact that the site will use cookies?

That's exactly what it is.

Re: Writing a Service Worker

#40
post #22

Earlier quoted context omitted.

What's the difference with Safari? (not a JS dev, so this is not familiar territory)

It's not just a safari problem, last I checked Chrome on iOS also does not support service workers, so you're just helping Android users. Apple has a vested interest in pushing users towards their walled garden for apps, while Google and Mozilla are trying to bring app-like experiences to the browser. There are hints of Safari supporting serviceworkers but I'm not holding my breath. Highly recommend Alex Russel's tal…

> you're just helping Android users

And desktop users of Chrome, Firefox, and soon Edge (which has support implemented behind a flag).

Post reply on HN