Skip to content

Commit

Permalink
Merge pull request #547 from us3r-network/B-pwaCleanCache-shixuewen
Browse files Browse the repository at this point in the history
fix: pwa clear cache
  • Loading branch information
friendlysxw authored Feb 12, 2024
2 parents 4933492 + a6a6df5 commit 43d2754
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions apps/u3/src/service-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,22 @@ self.addEventListener('push', (event) => {
});
});

// const CALL_BACK_INTERVAL = 1000 * 60 * 60;
// self.addEventListener('activate', () => {
// console.log('activate interval subscribe......');
// setInterval(() => {
// console.log('fire notification!');
// self.registration.showNotification('U3', {
// body: 'Checkout new content on Farcaster',
// icon: `${process.env.PUBLIC_URL}/logo192.png`,
// });
// }, CALL_BACK_INTERVAL);
// });
self.addEventListener('activate', function (event) {
// 清除旧缓存
event.waitUntil(
caches.keys().then(function (cacheNames) {
return Promise.all(
cacheNames
.filter(function (cacheName) {
// 过滤出旧的缓存
return cacheName.startsWith('main.');
// return cacheName !== 'my-cache';
})
.map(function (cacheName) {
// 删除旧的缓存
return caches.delete(cacheName);
})
);
})
);
});

0 comments on commit 43d2754

Please sign in to comment.