-
Notifications
You must be signed in to change notification settings - Fork 0
/
ServiceWorker.js
64 lines (56 loc) · 1.72 KB
/
ServiceWorker.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
const CACHE_NAME = 'offline-cache-v1';
const urlsToCache = [
// App
'index.js',
'ServiceWorker.js',
'/agenda',
'/requests',
'/history',
'app/agenda/agenda.html',
'app/agenda/AgendaController.js',
'app/agenda/AgendaHistoryController.js',
'app/common/AgendaService.js',
'app/common/ApiService.js',
'app/common/AuthService.js',
'app/common/ErrorHandler.js',
'app/requests/RequestsController.js',
'app/app.js',
'app/config.js',
'app/index.html',
'app/manifest.json',
// Style
'css/style.css',
// Images
'images/',
// Libs
'node_modules/angular/angular.min.js',
'node_modules/angular-route/angular-route.min.js',
'node_modules/angular-cookies/angular-cookies.min.js',
'node_modules/angular-messages/angular-messages.min.js',
'node_modules/angular-animate/angular-animate.min.js',
'node_modules/angular-aria/angular-aria.min.js',
'node_modules/angular-material/angular-material.min.js',
'node_modules/angular-material-data-table/dist/md-data-table.min.js',
'node_modules/angular-material-data-table/dist/md-data-table.min.css',
'node_modules/moment/min/moment.min.js',
'app/libs/moment/locale/pt-br.js',
'node_modules/angular-moment/angular-moment.min.js',
'node_modules/ngmap/build/scripts/ng-map.min.js',
];
self.addEventListener('install', (event) => {
// Perform install steps
event.waitUntil(
caches.open(CACHE_NAME).then((cache) => {
console.log("Caching...");
return cache.addAll(urlsToCache);
})
);
});
self.addEventListener('fetch', (event) => {
event.respondWith(
caches.match(event.request).then((response) => {
if (response) console.log(`Obtained from cache: ${event.request}`);
return response || fetch(event.request);
})
);
});