forked from unicef/iogt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request unicef#1247 from sheralim012/bug/offline-cache-for…
…-assets return assets urls for precache
- Loading branch information
Showing
73 changed files
with
89 additions
and
33 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...arty/workbox/workbox-v6.1.5/workbox-sw.js → ...c/js/workbox/workbox-v6.1.5/workbox-sw.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,38 @@ | ||
importScripts('../static/third_party/workbox/workbox-v6.1.5/workbox-sw.js'); | ||
|
||
importScripts('../../static/js/workbox/workbox-v6.1.5/workbox-sw.js'); | ||
|
||
// Below we are using a custom dimension to track online vs. offline interactions. So make | ||
// sure to create a custom dimension on GA | ||
|
||
workbox.googleAnalytics.initialize({ | ||
parameterOverrides: { | ||
cd1: 'offline', | ||
}, | ||
parameterOverrides: { | ||
cd1: 'offline', | ||
}, | ||
}); | ||
|
||
const precacheController = new workbox.precaching.PrecacheController(); | ||
|
||
self.addEventListener('install', event => { | ||
const resp = fetch(`${location.protocol}//${location.host}/sitemap/`) | ||
self.addEventListener('install', (event) => { | ||
const resp = fetch('/sitemap/') | ||
.then(response => response.json()) | ||
.then(urls => { | ||
precacheController.addToCacheList(urls.map(url => ({ | ||
url, | ||
revision: null, | ||
}))); | ||
workbox.precaching.precacheAndRoute(urls.map(url => ({ | ||
url, | ||
revision: null, | ||
}))); | ||
}) | ||
.then(() => { | ||
}).then(() => { | ||
// Passing in event is required in Workbox v6+ | ||
precacheController.install(event) | ||
}); | ||
event.waitUntil(precacheController.install(event)); | ||
}) | ||
event.waitUntil(resp); | ||
}); | ||
|
||
self.addEventListener('activate', (event) => { | ||
// Passing in event is required in Workbox v6+ | ||
event.waitUntil(precacheController.activate(event)); | ||
}); | ||
|
||
self.addEventListener('fetch', (event) => { | ||
event.respondWith( | ||
fetch(event.request) | ||
.catch(() => caches.match(event.request)) | ||
); | ||
}); |
This file contains 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