greatfire / redirect-when-blocked

Redirect your users to another URL if they can't reach your website
MIT License
95 stars 29 forks source link

ServiceWorker? #5

Closed requiredfield closed 9 years ago

requiredfield commented 9 years ago

Does ServiceWorker buy us anything over AppCache?

Just came across http://jakearchibald.com/2014/offline-cookbook/ which says:

When AppCache arrived on the scene it gave us a couple of patterns to make content work offline. If those were the patterns you needed, congratulations, you won the AppCache lottery (the jackpot remains unclaimed), but the rest of us were left huddled in a corner rocking back & forth.

With ServiceWorker (intro) we gave up trying to solve offline, and gave developers the moving parts to go solve it themselves. It gives you control over caching and how requests are handled. That means you get to create your own patterns. Let's take a look at a few possible patterns in isolation, but in practice you'll likely use many of them in tandem depending on URL & context.

All code examples work today in Chrome 40 beta with the cache polyfill, unless otherwise noted. This stuff will land into the stable version January/February 2015 barring any emergencies, so it won't be long until millions of real users can benefit from this stuff.

For a working demo of some of these patterns, see Trained-to-thrill, and this video showing the performance impact.

(cookbook contents follow)

If so, I guess we can keep an eye on https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker_API#Browser_support for support in other browsers.

requiredfield commented 9 years ago

/cc @willscott, and @jakearchibald (in case you have time to check out this use case; also thanks for the great ServiceWorker info!)

willscott commented 9 years ago

ServiceWorkers get you a much better experience, the issue is they aren't widely supported right now.

Application Cache is in 88.5% of browsers globally & 71% of chinese browsers, according to this site. Service Workers are just being implemented in chrome, and haven't propagated far enough yet to be widely available.

requiredfield commented 9 years ago

Tweet by Addy Osmani on 1/21/15, 18:00

Chrome 40 is now stable. Over 750 million users will soon have Service Workers. Time to make our apps work offline :)

greatfire-martin commented 9 years ago

Very interesting. given that google is highly blocked, to what extent will users inside GFW update their version of Chrome?

willscott commented 9 years ago

According to http://caniuse.com/#feat=serviceworkers there are currently 1% of worldwide users and 0.34% of Chinese users using browsers capable of service workers.

requiredfield commented 8 years ago

quoting https://twitter.com/FxSiteCompat/status/715908743351967744

Firefox Site Compat: Application Cache API removal has been approved. It will be gone from @FirefoxNightly first. Use Service Workers. bugzil.la/1237782