-
Notifications
You must be signed in to change notification settings - Fork 24
/
serviceWorker.js
55 lines (47 loc) · 1.52 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
// ---
// layout: null
// ---
// var cacheName = 'madhur-cache-v15';
// var filesToCache = [
// // Stylesheets
// // Pages and assets
// {% for page in site.html_pages %}
// {% if page.url contains 'projects' or page.url contains '404' %}
// {% else %}
// '{{ page.url }}',
// {% endif %}
// {% endfor %}
// // Blog posts
// {% for post in site.posts %}
// '{{ post.url }}',
// {% endfor %}
// // JS files, Portfolio assets and main video
// // (!) This will throw a Liquid error. Read below.
// {% for file in site.static_files %}
// {% if file.extname == '.js' or file.path contains '/portfolio/screenshots' or file.path contains '/portfolio/thumbnails' %}
// '{{ file.path }}',
// {% endif %}
// {% endfor %}
// ];
// // serviceWorker.js
// self.addEventListener('install', function(event) {
// event.waitUntil(
// caches.open(cacheName).then(function(cache) {
// return cache.addAll(filesToCache);
// })
// );
// });
// self.addEventListener('fetch', function(event) {
// event.respondWith(
// caches.match(event.request)
// .then(function(response) {
// if (response) {
// console.log('[*] Serving cached: ' + event.request.url);
// return response;
// }
// console.log('[*] Fetching: ' + event.request.url);
// return fetch(event.request);
// }
// )
// );
// });