I wouldn't let that stop you: adding a service work won't in any way degrade the experience of Safari users. When used for caching, it's pure progressive enhancement.
Sure, some browsers will have a more robust experience in adverse network conditions, but the experience once a page has loaded will be identical. It's also difficult to accidentally make the worker a hard dependency of a site, since even supported browsers will load the site without the worker on first visit.
> 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.
Service workers are really cool. I love them in using it in react project. In fact, create-react-app does inject a service worker for you to cache all the static files in production environment.
For one, it's deprecated. I've also found (at least during development) that it seems to cache too aggressively. Plus it lets you do weird things, like cache your appcache file. Combine that with caching the HTML, and you won't even be able to update your site until you clear the browser cache.
I do appreciate the surface simplicity, but the complexity under the surface makes it painful to use.
I had a project that was pretty much a perfect fit for the app cache:
- 100% static
- reasonable dataset size
- amenable url space (a few static files, then a large url
space that could fall back to serving out the index.html
file)
Despite this, the appcache just never worked reliably. It was a crapshoot whether it would actually work offline for any given user, I had to be careful not to permanently cache the appcache itself, and it was just generally inflexible and unpleasant.
From the top of your link: "Using the application caching feature described here is at this point highly discouraged; it’s in the process of being removed from the Web platform. Use Service Workers instead."
At least when following this example the site should work just fine when JS is disabled, which was the main issue I had when I tried following google's (?) tutorial on how to use service workers to make webapps work offline. That one revamped the whole site into a JS app powered by service workers, with a blank white page remaining without JS. Not the case here.
I don't think this approach here should cost much performance. It is just a thread checking a cache (that will be on disk) on page load.
Ah this is really nice but still feels quite verbose (+the web standards are know for their bad documentation for end devs). A small library with good documentation making things easier could kill it, similarly to localstorage, cookies, etc.
One of the more gnarly parts of ServiceWorker is having to clean up old caches during a version change. The workbox-build module generates revision hashes for your pre-cached assets and handles any cache clean ups for you.
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.
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).
It's browser specific. Most use a heuristic along the lines of allowing browser storage (inclusive of IndexedDB, etc.) to use a combined 50% of the device's otherwise free space. Usually each origin is limited to around 20% of that potential usage.
Could this be used to optionally reduce bandwidth use? For instance, could someone use this before going into Airplane Mode, even though they are in the middle of a city, but do not want to use wireless data?
Yep - that's one of the great things about service workers, IMO. The caching is pretty guaranteed, unlike the standard mobile caching which empties out far more often than you expect.
[+] [-] thrownblown|8 years ago|reply
[+] [-] callahad|8 years ago|reply
Sure, some browsers will have a more robust experience in adverse network conditions, but the experience once a page has loaded will be identical. It's also difficult to accidentally make the worker a hard dependency of a site, since even supported browsers will load the site without the worker on first visit.
[+] [-] tuxracer|8 years ago|reply
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.
[+] [-] akulbe|8 years ago|reply
[+] [-] antoaravinth|8 years ago|reply
[+] [-] CamelCaseName|8 years ago|reply
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.
[+] [-] fiveseven_|8 years ago|reply
[+] [-] resca79|8 years ago|reply
* Cache css, js and images file
* Defined cached entries page ex index.html, show.html etc..
* Fallback Entries
and it is really simple to use. https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_...
[+] [-] dlbucci|8 years ago|reply
[+] [-] rictic|8 years ago|reply
[+] [-] delta1|8 years ago|reply
Also: https://alistapart.com/article/application-cache-is-a-douche...
[+] [-] nannal|8 years ago|reply
[+] [-] onli|8 years ago|reply
I don't think this approach here should cost much performance. It is just a thread checking a cache (that will be on disk) on page load.
[+] [-] franciscop|8 years ago|reply
[+] [-] davideast|8 years ago|reply
One of the more gnarly parts of ServiceWorker is having to clean up old caches during a version change. The workbox-build module generates revision hashes for your pre-cached assets and handles any cache clean ups for you.
[+] [-] bluesign|8 years ago|reply
[+] [-] untog|8 years ago|reply
[+] [-] krallja|8 years ago|reply
[+] [-] danellis|8 years ago|reply
[+] [-] hdhzy|8 years ago|reply
[+] [-] fiatjaf|8 years ago|reply
https://github.com/fiatjaf/personal-graphs/blob/6182f5a40fec...
[+] [-] shinzui|8 years ago|reply
[+] [-] Zyst|8 years ago|reply
Damn it, if I'm going to have the song stuck in my head all day so should all of you!
https://www.youtube.com/watch?v=P5mtclwloEQ
[+] [-] unknown|8 years ago|reply
[deleted]
[+] [-] XCSme|8 years ago|reply
[+] [-] untog|8 years ago|reply
[+] [-] callahad|8 years ago|reply
[+] [-] stephengillie|8 years ago|reply
[+] [-] untog|8 years ago|reply
[+] [-] gramstrong|8 years ago|reply
[+] [-] detaro|8 years ago|reply
[+] [-] withholding|8 years ago|reply
[+] [-] FreeHugs|8 years ago|reply
[+] [-] eugenekolo2|8 years ago|reply
[+] [-] unknown|8 years ago|reply
[deleted]
[+] [-] Bakary|8 years ago|reply
[+] [-] aequitas720|8 years ago|reply
[+] [-] Eun|8 years ago|reply
[+] [-] icebraining|8 years ago|reply