Last active
August 30, 2019 04:46
-
-
Save fazlurr/a1729e39c67750ad3298018b9d6610ff to your computer and use it in GitHub Desktop.
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.registerNavigationRoute('/index.html') | |
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('/path/to/api/'), | |
new workbox.strategies.StaleWhileRevalidate({ | |
cacheName: 'api-cache', | |
plugins: [ | |
new workbox.cacheableResponse.Plugin({ | |
headers: { | |
'X-Is-Cacheable': 'true', | |
}, | |
}) | |
] | |
}) | |
); | |
workbox.routing.registerRoute( | |
new RegExp('^https://third-party\\.example\\.com/images/'), | |
new workbox.strategies.CacheFirst({ | |
cacheName: 'image-cache', | |
plugins: [ | |
new workbox.cacheableResponse.Plugin({ | |
statuses: [0, 200], | |
}) | |
] | |
}) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment