From 8261cf623400f81c9594bd9213351d42f8e70752 Mon Sep 17 00:00:00 2001 From: GURUAKASHSM <109951850+GURUAKASHSM@users.noreply.github.com> Date: Tue, 6 Feb 2024 15:28:53 +0530 Subject: [PATCH] Add files via upload --- projects/rock-paper-scissor/manifest.json | 20 ++++++++++++++++++++ projects/rock-paper-scissor/sw.js | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 projects/rock-paper-scissor/manifest.json create mode 100644 projects/rock-paper-scissor/sw.js diff --git a/projects/rock-paper-scissor/manifest.json b/projects/rock-paper-scissor/manifest.json new file mode 100644 index 0000000..c351dab --- /dev/null +++ b/projects/rock-paper-scissor/manifest.json @@ -0,0 +1,20 @@ +{ + "short_name": "Portfolio", + "name": "My PWA Portfolio", + "icons": [ + { + "src": "assets/images/logo.png", + "type": "image/png", + "sizes": "192x192" + }, + { + "src": "assets/images/logo.png", + "type": "image/png", + "sizes": "512x512" + } + ], + "start_url": "/index.html", + "background_color": "#000000", + "display": "standalone", + "theme_color": "#ff0000" + } \ No newline at end of file diff --git a/projects/rock-paper-scissor/sw.js b/projects/rock-paper-scissor/sw.js new file mode 100644 index 0000000..dcce614 --- /dev/null +++ b/projects/rock-paper-scissor/sw.js @@ -0,0 +1,20 @@ +// On install - caching the application shell +self.addEventListener('install', function(event) { + event.waitUntil( + caches.open('sw-cache').then(function(cache) { + // cache any static files that make up the application shell + return cache.add('index.html'); + }) + ); + }); + + // On network request + self.addEventListener('fetch', function(event) { + event.respondWith( + // Try the cache + caches.match(event.request).then(function(response) { + //If response found return it, else fetch again + return response || fetch(event.request); + }) + ); + }); \ No newline at end of file