This file contains hidden or 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
| let log = console.log; | |
| console.log = function() { | |
| log(""); | |
| log.apply(console, arguments); | |
| let info = new Error().stack.split(' at ')[2].trim().split(__dirname); | |
| log('-- from', '\x1b[33m', info[0].split(' (')[0], '\x1b[0m', 'at', '\x1b[33m', info[1], '\x1b[0m'); | |
| }; |
This file contains hidden or 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( |
This file contains hidden or 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(), | |
| ); |
This file contains hidden or 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 | |
| }), |
This file contains hidden or 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(); |
This file contains hidden or 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() | |
| ); |
This file contains hidden or 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: [ | |
| ... | |
| ] | |
| }); |
This file contains hidden or 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); |
This file contains hidden or 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( |
This file contains hidden or 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() | |
| ); |
OlderNewer