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