View workbox-routing-example.js
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', | |
}) | |
); |
View workbox-js-file-network-first-strategy.js
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() | |
); |
View handling-route-custom-callback-params.js
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( |
View handling-route-custom-callback.js
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); |
View workbox-strategy-options.js
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: [ | |
... | |
] | |
}); |
View cache-strategy-handler.js
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() | |
); |
View offline-google-analytics.js
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(); |
View cache-images.js
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 | |
}), |
View cache-js-css.js
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(), | |
); |
View cache-google-fonts.js
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