Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Cache Google Fonts - Webpack
// 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(
/^https:\/\/fonts\.gstatic\.com/,
workbox.strategies.cacheFirst({
cacheName: 'google-fonts-webfonts',
plugins: [
new workbox.cacheableResponse.Plugin({
statuses: [0, 200],
}),
new workbox.expiration.Plugin({
maxAgeSeconds: 60 * 60 * 24 * 365,
}),
],
}),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment