7 ms·
> I mean, where are service workers? Every discussion about anything in Safari on HN, even if not at all related, for the last year or two has included multipl
by MBCook 9y ago
> I mean, where are service workers?
Every discussion about anything in Safari on HN, even if not at all related, for the last year or two has included multiple people complaining about the lack of WebRTC.
Now it's here and there is a new complaint /s
I agree with threeseed that it probwont come and frankly I don't see why I'd want it (or web notification, or even WebRTC). They only seem to support the use case of replacing real apps with webpages which I don't want to do and makes no sense to me as an end user (I understand the freedom motivations).
- pfooti 9y agoWith service workers you can transparently intercept outgoing XHRs and replace their results with cached values. You can even do a cache race if you want (cancel the xhr if your cache returns first). This is a hugely important feature for making web apps work offline-first. I mean, it's also a big part of progressive web apps, which is the next thing I'm going to complain about. (I don't personally care much about webrtc, but I can see why people do care about it). The general point isn't about any one feature in particular. It is about a history safari has with not implementing (or half-heartedly implementing, as with indexeddb for so long) APIs that are important to making the web a useful platform. Reasonable people can disagree whether or not those features are good, but it seems basically true that my mobile web work is constrained by what iOS safari outright refuses to do, more than anything else.
- millstone 9y agoThis seems like a very strange API. Why do you need a proxy to intercept network requests coming from your own app?
- reitanqild 9y agoTo serve that requests from local storage if your device or the server is offline.
- millstone 9y agoIf the asset is already in local storage, why do you need to create a network request in the first place?
- zachrose 9y agoOr why can't this problem be solved with HTTP caching headers and a browser that Does the Right Thing?
- cormacrelf 9y agoI'm pretty sure HTTP caching headers don't provide a guarantee that they will be stored for any length of time at all, the browser is free to empty it at will. They also don't guarantee that all your cached assets will be valid with respect to each other (ie your browser might cache an HTML file but not the content it refers to). Most importantly, though, you can't simply disable HTTP caching when you notice that you're back online. Those cache entries are there now, and they're hard to get out. Service Workers, on the other hand, will just transparently stop intercepting stuff. With respect to localStorage, I think the idea is that you absolutely can do almost an entire offline mode with it, with the caveat that your content (html, js, css, images) won't get stored there, so you can't load the page at all! Also I think there are considerations about how difficult it is for many front end architectures to implement this transparent fallback themselves. If you're a Redux or ClojureScript type of programmer it might be utterly obvious and even trivial to implement (just add a simple middleware), but sadly not everyone is, and a lot of the offline logic would have to be implemented everywhere in your codebase. A service worker lets you do it all in one place. It's a toss-up whether to use localStorage or a service worker if you could viably do either. Blanket logic over all your HTTP calls would be easier in a service worker, and more customized logic would be easier in localStorage, I'm guessing.
- cormacrelf 9y agoJust to articulate the difference on HTTP caching again: Using HTTP caching for saying how long online clients should keep a value becomes impossible if you want to tell browsers to store things forever in offline mode. HTTP caching makes no distinction between whether you're online or offline.
- pjmlp 9y agoIt is yet another hack web developers come up with, as workaround for offline apps.
- pier25 9y ago> my mobile web work is constrained by what iOS safari outright refuses to do You are privileged to be able to work with Safari. Imagine if you had to work with its bastard deformed brothers WKWebView and UIWebView.
- Vinnl 9y agoA complaint you haven't seen, however, is lack of ES6 support - which means it's still baffling that there's so much focus on that. (That said, the complaint was always lack of WebRTC and ServiceWorker support.)
- allover 9y ago> the complaint was always lack of WebRTC and ServiceWorker support You have a source for that? To me nobody really started caring about ServiceWorker until the big push recently for PWAs w/ launch of Lighthouse etc. Whereas devs have always wanted browsers to keep up with JS/ES/CSS language standards. Also "development doesn't really work like that". Who's to say the same devs implementing ES6 features could take on ServiceWorker. Maybe there's something in the codebase blocking ServiceWorker. You just don't know. Assuming one thing is being neglected in favour of the other is a huge assumption. I feel like the internet getting angry that 'feature 1' is released whilst the 'feature 2' they want isn't, and being all 'why are they spending all their time on feature 1 instead of working on my thing' is such an old trope there should be a term for it. (But yeah I'd like to see ServiceWorker in Safari too, though please let's not bite the hand that feeds)!
- positivecomment 9y agoWell, lack of ServiceWorker support by itself was a complaint, that's for sure: https://www.google.com/search?q=site%3Anews.ycombinator.com+ServiceWorker+safari https://www.google.com/search?q=site%3Anews.ycombinator.com+...
- Vinnl 9y ago> You have a source for that? Well, same as yours: I've seen people ask for that on Hacker News in the past. Of course, there will also have been people asking about WebRTC :) My beef has mostly been with SW though. Of course, with many developers, there will always be some that have asked for one, and some for the other. I highly doubt that someone will chime in saying that they've seen people complaining about lack of ES6 support in Safari, though :) > Maybe there's something in the codebase blocking ServiceWorker. You just don't know. Assuming one thing is being neglected in favour of the other is a huge assumption. Yes, this is true. That's why it's mostly "baffling", i.e. I wonder if something like you described is actually the case, or whether it's a case of different priorities or something.
- littlestymaar 9y ago> Every discussion about anything in Safari on HN, even if not at all related, for the last year or two has included multiple people complaining about the lack of WebRTC. > Now it's here and there is a new complaint /s WebRTC is 6 years old and it's been implemented in Firefox and Chrome for 5 years now ! Since then there's plenty of other DOM API that where introduced and are not supported in webkit, for instance : - service workers - push API - Fetch API - User Timing API - Subresource Integrity On the JavaScript side, the JSC team has been doing a great job for the past two years, leading the way in term of performance and ES2015+ support, but on the DOM side, Safari is really lagging far behind (which is, I guess, probably because they don't want the compete with there native mobile apps).
- floatboth 9y agoFetch is supported in 10.1 (only 2 years after Firefox and Chromium!) They also already have Custom Elements v1 support, which is still in progress in Firefox. Timing and SRI they announced in this release (11). Service Workers is THE big gap, at this point it feels like they're actually very afraid of progressive web apps.
- rhinoceraptor 9y agoWasn't the original idea for the iPhone to just use web apps in place of native?
- floatboth 9y agoThat was the only way to add apps on iPhone OS 1.0, yes. Maybe they already had the App Store in mind and intended that as a stopgap, maybe the App Store was a reaction to jailbreaks and unofficial app development…
- johngruber 9y agoBut it's like saying people complain about Internet Explorer not having a feature that other browsers have. When it takes many years longer than the other browsers to implement a feature, you are effectively holding the market back. IE and Safari are the only two browsers that didn't have support until now (with only IE not having support while Edge does).