debugging PWA functionality
This commit is contained in:
parent
c2c34d96ec
commit
e50ece4fbc
3 changed files with 25 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Exchange Rate Calculator</title>
|
<title>EUR DZD</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="manifest" href="/manifest.json">
|
<link rel="manifest" href="/manifest.json">
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "EUR-DZD Calculator",
|
"name": "EUR-DZD Calculator",
|
||||||
"short_name": "Exchange Calculator",
|
"short_name": "EUR DZD",
|
||||||
"icons": [
|
"icons": [
|
||||||
{
|
{
|
||||||
"src": "icon.png",
|
"src": "icon.png",
|
||||||
|
|
|
@ -8,6 +8,8 @@ self.addEventListener('install', function(event) {
|
||||||
'/index.html',
|
'/index.html',
|
||||||
'/manifest.json',
|
'/manifest.json',
|
||||||
'/icon.png',
|
'/icon.png',
|
||||||
|
'/style.css',
|
||||||
|
'/script.js',
|
||||||
]);
|
]);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -20,7 +22,27 @@ self.addEventListener('fetch', function(event) {
|
||||||
if (response) {
|
if (response) {
|
||||||
return 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);
|
||||||
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue