Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PWA minimal service worker just for trigger the install button?

What is the minimal service worker just for trigger the install button?

I don't want cacheing anything and the app can't works in offline mode, but i want allow users to create a shortcut on the desktop.

like image 982
Simone Nigro Avatar asked Jan 01 '23 04:01

Simone Nigro


2 Answers

The "ultra" minimal service worker is

self.addEventListener('fetch', function() {
    return;
});

No need to do something into fetch method

like image 193
ar099968 Avatar answered Jan 14 '23 03:01

ar099968


Seems like the minimal service worker would be this one

self.addEventListener('fetch', function(event) {
  event.respondWith(fetch(event.request));
});

Taken from the Google Developers PWA documentation

like image 24
Segfault Avatar answered Jan 14 '23 03:01

Segfault