Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offline support with a Service Worker #109

Open
1j01 opened this issue Apr 5, 2018 · 6 comments · May be fixed by #144
Open

Offline support with a Service Worker #109

1j01 opened this issue Apr 5, 2018 · 6 comments · May be fixed by #144

Comments

@1j01
Copy link
Owner

1j01 commented Apr 5, 2018

The key thing here is to make sure the service worker and the path to the service worker can be changed easily in the future.
Refreshing should always get you the newest version if you're online.

@maxjf1
Copy link

maxjf1 commented Dec 8, 2020

Analyzing the app in lighthouse, the following problems are found in the PWA session. By adding the service worker and fixing some icons (there are some great icons generators) it should work

image

@1j01
Copy link
Owner Author

1j01 commented Dec 25, 2020

Icons are not a problem.
Service workers are a huge foot-gun. I've never heard of pleasant experiences with them.
It's easy to leave users on an old version of an app, breaking the refresh button and requiring users to close every tab of the app before they can get it to update, or even leaving them stranded forever, with a cached service worker that can't update itself.
It requires a lot of thought, and frankly I don't know if anyone's solved the core issues with service workers.

@maxjf1
Copy link

maxjf1 commented Jan 4, 2021

Icons are not a problem.
Service workers are a huge foot-gun. I've never heard of pleasant experiences with them.
It's easy to leave users on an old version of an app, breaking the refresh button and requiring users to close every tab of the app before they can get it to update, or even leaving them stranded forever, with a cached service worker that can't update itself.
It requires a lot of thought, and frankly I don't know if anyone's solved the core issues with service workers.

I never write an SW from scratch, but used a lot the ones generated by React CRA for instance, and i never had those problems. I think it can be automatically done by webpack, with some configuration. You will only mess it up if you don't undestand it well to use.

About leaving users in a old version of the app and closing every tab of the app to update, normally SW warns you when it has updated, and its your choice how to handle the window update. You can Display a poupo that refreshes the window when clicked, or if your app allow it, just refresh the window (if no data will be lost).

About using a cached version forever, it only happens if you mess the versioning generated in the SW (normally it doesn't happen). What normally happens is turning the development mode very exausting when cache enabled (just add a tag for development to disable it)

@justingolden21
Copy link

Hey just stepping in to say I love this project, +1 to the PWA idea

@LiquidITGuy
Copy link

@maxjf1 the default mode of create react app and vue cli have this problem.

@1j01 with custom service worker (handly written) we can use network first for static assets instead of stale while revalidate to prevent all the things you previously explain

@maxjf1
Copy link

maxjf1 commented Oct 29, 2021

@maxjf1 the default mode of create react app and vue cli have this problem.

@1j01 with custom service worker (handly written) we can use network first for static assets instead of stale while revalidate to prevent all the things you previously explain

i've created many PWAs with CRA. the only problem i've found is icons size. For this, i use an icon generator that generate all icons and a manifest.json file. Them it's just a matter of putting the icons on the public file and updating the manifest.json, there is no need to rewrite service workes, CRA SW works perfectly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants