sw
This commit is contained in:
parent
29622d3c0c
commit
2f8ff69aee
@ -17,5 +17,14 @@
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
<script>
|
||||
// Check that service workers are registered
|
||||
if ('serviceWorker' in navigator) {
|
||||
// Use the window load event to keep the page load performant
|
||||
window.addEventListener('load', () => {
|
||||
navigator.serviceWorker.register('./service.worker.js');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<script src="./index.js"></script>
|
||||
</html>
|
||||
13
client/service.worker.js
Normal file
13
client/service.worker.js
Normal file
@ -0,0 +1,13 @@
|
||||
self.addEventListener('fetch', function(event) {
|
||||
event.respondWith(
|
||||
caches.match(event.request)
|
||||
.then(function(response) {
|
||||
// Cache hit - return response
|
||||
if (response) {
|
||||
return response;
|
||||
}
|
||||
return fetch(event.request);
|
||||
}
|
||||
)
|
||||
);
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user