diff options
| author | Alireza Ahmand <mr.alireza.ahmand@gmail.com> | 2024-02-17 19:23:22 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-17 19:23:22 +0300 |
| commit | 3a503f12c8826fa7197f08f5af50c1911f3adcfe (patch) | |
| tree | 7b884e5572be93c561ab28edde895c4b3865b1a0 /web/assets/js | |
| parent | 2b7ad7cb9b0ea29f00b739905de0628ae9f166f9 (diff) | |
Progressive Web App (#1678)
* pwa support
* Create go.yml
* Delete .github/workflows/go.yml
Diffstat (limited to 'web/assets/js')
| -rw-r--r-- | web/assets/js/sw.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/web/assets/js/sw.js b/web/assets/js/sw.js new file mode 100644 index 00000000..46cf61c4 --- /dev/null +++ b/web/assets/js/sw.js @@ -0,0 +1,39 @@ +var self = this; + +var filesToCache = [ + '/' +]; + +self.addEventListener('install', function (e) { + e.waitUntil( + caches.open('3xPanel').then(function (cache) { + return cache.addAll(filesToCache); + }) + ); +}); +self.addEventListener('activate', function (event) { + event.waitUntil( + caches.keys().then(function (cacheNames) { + return Promise.all( + cacheNames.filter(function (cacheName) { + }).map(function (cacheName) { + return caches.delete(cacheName); + }) + ); + }) + ); +}); +self.addEventListener('fetch', function (event) { + event.respondWith( + caches.open('mysite-dynamic').then(function (cache) { + return cache.match(event.request).then(function (response) { + return response || fetch(event.request).then(function (response) { + cache.put(event.request, response.clone()); + return response; + }); + }); + }) + ); +}); + +console.clear();
\ No newline at end of file |
