mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-04-29 10:45:01 -04:00
Remove cache
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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;
|
||||
// });
|
||||
// });
|
||||
// })
|
||||
// );
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user