From 3a503f12c8826fa7197f08f5af50c1911f3adcfe Mon Sep 17 00:00:00 2001 From: Alireza Ahmand Date: Sat, 17 Feb 2024 19:53:22 +0330 Subject: Progressive Web App (#1678) * pwa support * Create go.yml * Delete .github/workflows/go.yml --- web/assets/js/sw.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 web/assets/js/sw.js (limited to 'web/assets/js') 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 -- cgit v1.2.3