Skip to content

Instantly share code, notes, and snippets.

@MrPeker
Created January 27, 2019 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MrPeker/00617c8b0f536360600a92270ffa0c96 to your computer and use it in GitHub Desktop.
Save MrPeker/00617c8b0f536360600a92270ffa0c96 to your computer and use it in GitHub Desktop.
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',
})
);
workbox.routing.registerRoute(
// Resim dosyalarını önbellekle
/.*\.(?:png|jpg|jpeg|svg|gif)/,
// Önbellek kullanılabilirse onu kullan
workbox.strategies.cacheFirst({
// Özel önbellek ismi kullan
cacheName: 'image-cache',
plugins: [
new workbox.expiration.Plugin({
// Sadece 20 resimi önbellekte tut
maxEntries: 20,
// Önbellekte en fazla 1 hafta boyunca dursunlar
maxAgeSeconds: 7 * 24 * 60 * 60,
})
],
})
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment