more pwa stuff

This commit is contained in:
Kasper Rynning-Tønnesen
2020-01-29 17:51:09 +01:00
parent 2d7de7c62b
commit 13e8f47b35
5 changed files with 27 additions and 14 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View File

@@ -11,6 +11,16 @@
"src": "/public/assets/images/android-chrome-144x144.png", "src": "/public/assets/images/android-chrome-144x144.png",
"sizes": "144x144", "sizes": "144x144",
"type": "image/png" "type": "image/png"
},
{
"src": "/public/assets/images/192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/public/assets/images/512x512.png",
"sizes": "512x512",
"type": "image/png"
} }
], ],
"theme_color": "#daeedd", "theme_color": "#daeedd",

View File

@@ -30,16 +30,17 @@ self.addEventListener("fetch", event => {
event.respondWith( event.respondWith(
fetch(event.request) fetch(event.request)
.then(response => cache(event.request, response)) .then(response => cache(event.request, response))
.catch(function() { .catch(() => caches.match(event.request))
return caches.match(event.request);
})
); );
}); });
function cache(request, response) { function cache(request, response) {
//console.log(response.type === "error" || response.type === "opaque", request); if (
if (response.type === "error" || response.type === "opaque") { response.type === "error" ||
return response; !(response.url.includes("http:") && response.url.includes("https:")) ||
response.url == ""
) {
return Promise.resolve(response);
} }
return caches.open(CACHE_NAME).then(cache => { return caches.open(CACHE_NAME).then(cache => {

View File

@@ -57,6 +57,8 @@ noscript {
justify-content: center; justify-content: center;
align-items: center; align-items: center;
height: 100vh; height: 100vh;
background-color: #dbeede;
font-size: 1.5rem; font-size: 1.5rem;
font-family: Arial, Helvetica, sans-serif;
} }
</style> </style>