Skip to content

Instantly share code, notes, and snippets.

💭
I may be slow to respond.

Mehmet Ali Peker MrPeker

💭
I may be slow to respond.
Block or report user

Report or block MrPeker

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View workbox-routing-example.js
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
workbox.routing.registerRoute(
new RegExp('.*\.js'),
workbox.strategies.networkFirst()
);
View handling-route-custom-callback-params.js
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
const handler = ({url, event}) => {
return new Response(`Custom handler response.`);
};
workbox.routing.registerRoute(match, handler);
View workbox-strategy-options.js
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
workbox.routing.registerRoute(
match,
workbox.strategies.staleWhileRevalidate()
);
workbox.routing.registerRoute(
match,
workbox.strategies.networkFirst()
);
@MrPeker
MrPeker / offline-google-analytics.js
Created Jan 27, 2019
Offline Google Analytics Workbox
View offline-google-analytics.js
workbox.googleAnalytics.initialize();
@MrPeker
MrPeker / cache-images.js
Last active Jan 27, 2019
Cache Images Workbox
View cache-images.js
// 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
}),
@MrPeker
MrPeker / cache-js-css.js
Created Jan 27, 2019
Cache Javascript and CSS Workbox
View cache-js-css.js
// Stale While Revalidate stratejisiyle CSS ve JS varlıklarınızı önbellekleyin
workbox.routing.registerRoute(
/\.(?:js|css)$/,
workbox.strategies.staleWhileRevalidate(),
);
@MrPeker
MrPeker / cache-google-fonts.js
Created Jan 27, 2019
Cache Google Fonts - Webpack
View cache-google-fonts.js
// 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(
You can’t perform that action at this time.