Skip to content

Commit

Permalink
Create service-worker.js
Browse files Browse the repository at this point in the history
  • Loading branch information
wanghaisheng authored Dec 15, 2024
1 parent 3c4019f commit 633afe9
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions service-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open('mobile-simulator-cache').then((cache) => {
return cache.addAll([
'/',
'/index.html',
'/manifest.json',
'/favicon.ico',
'/style.css'
]);
})
);
});

self.addEventListener('fetch', (event) => {
event.respondWith(
caches.match(event.request).then((cachedResponse) => {
return cachedResponse || fetch(event.request);
})
);
});

0 comments on commit 633afe9

Please sign in to comment.