Skip to content

Instantly share code, notes, and snippets.

@MrPeker
Created January 27, 2019 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrPeker/a3dec2158c91be91f975ad2c7015ee7d to your computer and use it in GitHub Desktop.
Save MrPeker/a3dec2158c91be91f975ad2c7015ee7d to your computer and use it in GitHub Desktop.
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