forked from haideralipunjabi/covid19kashmir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw.js
69 lines (67 loc) · 1.61 KB
/
sw.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
importScripts('https://storage.googleapis.com/workbox-cdn/releases/5.1.2/workbox-sw.js');
workbox.googleAnalytics.initialize()
workbox.routing.registerRoute(
/assets/,
new workbox.strategies.StaleWhileRevalidate({
cacheName: 'static-files',
plugins: [
new workbox.expiration.ExpirationPlugin({
purgeOnQuotaError: true,
})
]
})
)
workbox.routing.registerRoute(
/\.html$/,
new workbox.strategies.StaleWhileRevalidate({
cacheName: 'webpages',
plugins: [
new workbox.expiration.ExpirationPlugin({
purgeOnQuotaError: true,
})
]
})
)
workbox.routing.registerRoute(
/api\/news/,
new workbox.strategies.StaleWhileRevalidate({
cacheName: 'newsfeed',
plugins:[
new workbox.expiration.ExpirationPlugin({
purgeOnQuotaError:true,
})
]
})
)
workbox.routing.registerRoute(
/api\/live/,
new workbox.strategies.NetworkOnly()
)
workbox.routing.registerRoute(
/api/,
new workbox.strategies.NetworkFirst()
)
workbox.routing.registerRoute(
/api\/live/,
new workbox.strategies.NetworkOnly()
)
var version = "v2.0.2";
var swPath;
var urlObject = new URL(location);
var host;
if (urlObject.searchParams.get("swPath")) {
swPath = urlObject.searchParams.get("swPath");
}
else {
if (urlObject.searchParams.get("version")) {
version = urlObject.searchParams.get("version");
}
if (urlObject.searchParams.get("swJSHost")) {
host = "https://" + urlObject.searchParams.get("swJSHost");
}
else {
host = "https://sdki.truepush.com/sdk/";
}
swPath = host + version + "/sw.js";
}
importScripts(swPath);