Remove cache

This commit is contained in:
MartinBraquet
2025-10-22 00:38:56 +02:00
parent fa44e348a2
commit 7311d4b724
2 changed files with 24 additions and 24 deletions

View File

@@ -51,7 +51,7 @@ function MyApp({Component, pageProps}: AppProps<PageProps>) {
useHasLoaded()
useEffect(() => {
console.log('registering service worker...');
console.log('Registering service worker...');
if ('serviceWorker' in navigator) {
navigator.serviceWorker
.register('/service-worker.js')

View File

@@ -1,6 +1,6 @@
console.log('SW loaded');
const CACHE_NAME = 'compass-cache-v1';
// const CACHE_NAME = 'compass-cache-v1';
self.addEventListener('install', (event) => {
console.log('SW installing…');
@@ -12,26 +12,26 @@ self.addEventListener('activate', (event) => {
});
self.addEventListener('fetch', (event) => {
const url = new URL(event.request.url);
// Ignore Next.js dev HMR and static chunks
if (url.pathname.startsWith('/_next/') || url.pathname.startsWith('/__next/')) {
return;
}
event.respondWith(
caches.match(event.request).then((cachedResponse) => {
if (cachedResponse) return cachedResponse;
return fetch(event.request).then((networkResponse) => {
return caches.open(CACHE_NAME).then((cache) => {
// Only cache GET requests to same-origin
if (event.request.method === 'GET' && event.request.url.startsWith(self.location.origin)) {
cache.put(event.request, networkResponse.clone());
}
return networkResponse;
});
});
})
);
// const url = new URL(event.request.url);
//
// // Ignore Next.js dev HMR and static chunks
// if (url.pathname.startsWith('/_next/') || url.pathname.startsWith('/__next/')) {
// return;
// }
//
// event.respondWith(
// caches.match(event.request).then((cachedResponse) => {
// if (cachedResponse) return cachedResponse;
//
// return fetch(event.request).then((networkResponse) => {
// return caches.open(CACHE_NAME).then((cache) => {
// // Only cache GET requests to same-origin
// if (event.request.method === 'GET' && event.request.url.startsWith(self.location.origin)) {
// cache.put(event.request, networkResponse.clone());
// }
// return networkResponse;
// });
// });
// })
// );
});