pwa-update-available | Service Workers - New Update Available sample
kandi X-RAY | pwa-update-available Summary
kandi X-RAY | pwa-update-available Summary
Have you ever been on a website and noticed a popup notification that suggests that there is a new version of the site available? I recently visited Google’s Inbox and noticed a notification a little like the image below. If you'd like to learn how to create this for your site and for a step by step guide, please visit my blog at deanhume.com. This repo contains a basic example that will show you how to add a notification to your site and display it each time that there is a new version of the service worker available. You’ll also learn how to refresh the page, so that the user is up to date and has the latest version of any cached files.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of pwa-update-available
pwa-update-available Key Features
pwa-update-available Examples and Code Snippets
Community Discussions
Trending Discussions on pwa-update-available
QUESTION
Following this link https://github.com/deanhume/pwa-update-available, I am trying to implement the service worker update, but I am facing issues like the event update is not getting triggered, which I think is related to my app design, which basically a SPA, means I am always on index.html,which behaves like app-shell and I am pushing the contents in the contents area, depending upon which button is clicked.
only other page is login/index.html
the contents for app.js to install/update service worker is like this:
...ANSWER
Answered 2019-Nov-03 at 23:30the service worker registration routine you have only triggers when you index.html is loaded in the browser. It is the only time that code is executed.
Unless you periodically poll your server or possibly open a websocket (sort of expensive just for this) you wont know if a new service worker is available. You could have the user register for push notifications....too much headache for this.
So pool the server every few hours or days for an update.
If there is an update you can trigger an update routine.
I would put the polling logic in the actual service worker code to keep it off the UI, if you are a SPA you are already locking the UI thread enough LOL.
There are lots of ways to skin this cat, setTimeout(..., {lots of seconds}), when the service worker wakes from being dormant, etc.
If you can make a HEAD request that would keep the network traffic to a minimum.
If there is an update you could then post a message to the UI to update the service worker.
This is not what I would call trivial code. I do similar stuff to keep my cached assets up to date, so I have been there :)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pwa-update-available
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page