News for hackers. Stuff that matters.
Re:What's New in Create React App by Kiro on Friday May 19, 2017 @02:29AM (#14373413)
Why do you need a service worker for caching? I thought the browsers did this by default.
Re:What's New in Create React App by Softcadbury on Friday May 19, 2017 @03:00AM (#14373509)
This is offline cache, you can run your application even without internet connection.
Re:What's New in Create React App by Kiro on Friday May 19, 2017 @03:27AM (#14373596)
What are some examples where offline works for a web app? It seems like the utility is really niched so I don't understand why they make this default. None of the things I've made would make sense using offline (completely anecdotal but still).
Re:What's New in Create React App by mbrock on Friday May 19, 2017 @05:20AM (#14373985)
I don't know about making it the default, because there are tradeoffs with regard to the cache invalidation.

That said, offline-friendly app caching with Service Workers is extremely useful, and changed the way I see and make web apps.

Now when I use a web app that isn't offline-friendly, I get annoyed. Always demanding a live internet connection obviously creates latency and unreliability for apps.

I changed a former client's app to be offline-friendly with Service Workers, and the benefit was obvious: their app now loaded immediately for repeat users, and they could access much of their data even when they were offline (on a flight, on a crappy Wi-Fi, etc etc).

I made a side-project to help my band members share and edit chord/lyrics sheets (also using Web Audio to give karaoke-style chord playback!) and again I made sure to set up full Service Worker caching. I also used PouchDB for the user data, which was beautiful: I didn't need to run any database server (we just used Cloudant's free instances), all our songs were synced into local browser storage (in real-time when online), and most importantly, the whole app worked perfectly while in the basement rehearsal space that completely blocks mobile signals.

(I'm not working on it nowadays. It's up on https://sketch.band and the code is at https://github.com/mbrock/sketchband under AGPL3. If you wanna try it, the undocumented syntax for the song is: each line should look like "C Dm7 / Once upon a time you dressed so fine".)

Basically offline-first technologies really help make the web into a good platform for apps.

Re:What's New in Create React App by Vinnl on Friday May 19, 2017 @03:43AM (#14373646)
An example is a webmail client, where in offline mode you can schedule new emails to be sent as soon as you get online again, and where you can still read the emails you've read before.
Re:What's New in Create React App by capisce on Friday May 19, 2017 @05:54AM (#14374143)
Isn't it the case that the offline resources are considered "caches" and thus might be cleaned up if there's not much storage left?
Re:What's New in Create React App by Vinnl on Friday May 19, 2017 @07:19AM (#14374511)
Yes, as far as I know, storage space is still limited, so you wouldn't want to be storing GBs of offline emails. I'm not sure how enforcing works nowadays - it used to be that old offline data would be culled (I think that was for AppCache), but that might work differently with Service Workers.
Re:What's New in Create React App by konradkpl on Friday May 19, 2017 @05:16AM (#14373959)
There are a lot of strategies for supporting offline state in your app: https://jakearchibald.com/2014/offline-cookbook/

In dashboard application, I store data in browser and notify users about last sync time: http://wstaw.org/m/2017/05/19/dashboard.livechatinc.com-iPho...

Re:What's New in Create React App by danabramov on Friday May 19, 2017 @06:53AM (#14374395)
It‘s not just about offline, but about serving assets instantly on repeated visits (while they update in background). You don’t need to wait for request at all.
Re:What's New in Create React App by coldtea on Friday May 19, 2017 @03:37AM (#14373628)
>What are some examples where offline works for a web app?

Tons of web apps that work in offline mode, which we had since a decade or so -- from games to utility apps.

>It seems like the utility is really niche

Hardly.

Re:What's New in Create React App by GeneralMaximus on Friday May 19, 2017 @04:20AM (#14373759)
It's also nice to be able to selectively cache some data offline so that users aren't greeted with a "you are offline" screen when they hit your web page without a network connection.

For an e-commerce website, this might be the user's shopping cart and favorites. For a note taking app, this might be the last note the user edited. For a Twitter client, this might be the user's drafts and the last 100 tweets on their timeline. This way, the app can say "you're offline, but you can still look at some of this data and do things with it, and we'll sync you up when you get back online".

Native apps already do this. E.g, try posting a picture to Instagram while you're offline.