I recently turned a website into a PWA using workbox and added to my home screen on my android device. However, when I update the website, the PWA does not update on android.
Below is the code manifest.json code:
{"short_name":"SSPNG","name":"Security Shields PNG Limited","icons":[{"src":"/assets/img/fb-pro-pic0.png","type":"image/png","sizes":"512x512"},{"src":"/assets/img/fb-pro-pic0.png","type":"image/png","sizes":"512x512"}],"start_url":"/index.html","background_color":"#fff","theme_color":"#fff","display":"standalone","orientation":"portrait"}
Here is the service-worke registration code:
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js')
.then(registration => {
console.log('Service Worker registered! ');
})
.catch(err => {
console.log('Registration failed ', err);
});
});
}
</script>
I am looking for a solution where users don't need to manually clear the cache form browser app storage and that the PWA automatically gets updated. I think I used the cache fallback method and I am seeking an alternative relief that forcefully updates the cache in the existing PWA.