diff --git a/index.html b/index.html index 9a44fc8..708481a 100644 --- a/index.html +++ b/index.html @@ -1,7 +1,7 @@ - Exchange Rate Calculator + EUR DZD diff --git a/manifest.json b/manifest.json index 77ff8b2..0a6ff9e 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "EUR-DZD Calculator", - "short_name": "Exchange Calculator", + "short_name": "EUR DZD", "icons": [ { "src": "icon.png", diff --git a/service-worker.js b/service-worker.js index 7fc11d4..db1dba7 100644 --- a/service-worker.js +++ b/service-worker.js @@ -8,6 +8,8 @@ self.addEventListener('install', function(event) { '/index.html', '/manifest.json', '/icon.png', + '/style.css', + '/script.js', ]); }) ); @@ -20,7 +22,27 @@ self.addEventListener('fetch', function(event) { if (response) { return response; } - return fetch(event.request); + + let fetchRequest = event.request.clone(); + + return fetch(fetchRequest) + .then(function(response) { + if (!response || response.status !== 200 || response.type !== 'basic') { + return response; + } + + let responseToCache = response.clone(); + + caches.open(CACHE_NAME) + .then(function(cache) { + cache.put(event.request, responseToCache); + }); + + return response; + }) + .catch(function(error) { + console.error('Error fetching and caching:', error); + }); }) ); });