You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
592 B
JavaScript
21 lines
592 B
JavaScript
self.addEventListener('install', (event) => {
|
|
console.log("Service worker installed")
|
|
});
|
|
|
|
self.addEventListener('activate', (event) => {
|
|
console.log("Service worker activated")
|
|
});
|
|
|
|
self.addEventListener('fetch', (event) => {
|
|
try {
|
|
return fetch(event.request)
|
|
} catch (error) {
|
|
return new Response(
|
|
"<h1>No network connection</h1>Retrying...<script>setTimeout(() => { window.location.reload(1); }, 5000);</script>",
|
|
{
|
|
headers: {
|
|
'Content-type': 'text/html'
|
|
}
|
|
})
|
|
}
|
|
}); |