This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
workbox.routing.registerRoute( | |
// CSS dosyalarını önbellekle | |
/.*\.css/, | |
// Önbelleği kullan ama mümkün olduğunda arkaplanda güncelle | |
workbox.strategies.staleWhileRevalidate({ | |
// Özel önbellek ismi kullan | |
cacheName: 'css-cache', | |
}) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
workbox.routing.registerRoute( | |
new RegExp('.*\.js'), | |
workbox.strategies.networkFirst() | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const match = ({url, event}) => { | |
return { | |
name: 'Workbox', | |
type: 'guide', | |
}; | |
}; | |
const handler = ({url, event, params}) => { | |
// Yanıt “A guide on Workbox” olacaktır | |
return new Response( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const handler = ({url, event}) => { | |
return new Response(`Custom handler response.`); | |
}; | |
workbox.routing.registerRoute(match, handler); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
workbox.strategies.staleWhileRevalidate({ | |
// Bu rota için özel isim kullan | |
cacheName: 'my-cache-name', | |
// Özel eklentiler dizisi ekle (örneğin workbox.expiration.Plugin) | |
plugins: [ | |
... | |
] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
workbox.routing.registerRoute( | |
match, | |
workbox.strategies.staleWhileRevalidate() | |
); | |
workbox.routing.registerRoute( | |
match, | |
workbox.strategies.networkFirst() | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
workbox.googleAnalytics.initialize(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cache First stratejisiyle resimlerinizi önbellekleyin | |
workbox.routing.registerRoute( | |
/\.(?:png|gif|jpg|jpeg|svg)$/, | |
workbox.strategies.cacheFirst({ | |
cacheName: 'images', | |
plugins: [ | |
new workbox.expiration.Plugin({ | |
maxEntries: 60, | |
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 Gün | |
}), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Stale While Revalidate stratejisiyle CSS ve JS varlıklarınızı önbellekleyin | |
workbox.routing.registerRoute( | |
/\.(?:js|css)$/, | |
workbox.strategies.staleWhileRevalidate(), | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Google Fonts stil dosyalarını Stale While Revalidate stratejisi ile önbellekleyin | |
workbox.routing.registerRoute( | |
/^https:\/\/fonts\.googleapis\.com/, | |
workbox.strategies.staleWhileRevalidate({ | |
cacheName: 'google-fonts-stylesheets', | |
}), | |
); | |
// Google Fonts webfont dosyalarını Cache First stratejisiyle bir yıllığına önbellekleyin | |
workbox.routing.registerRoute( |
NewerOlder