---
layout: null
---
 
const staticCacheName = "gdad-s-river-static-v61";
 
console.log("installing service worker");
 
const filesToCache = [
  "/",
  {% for page in site.html_pages %}
    '{{ page.url }}',
  {% endfor %}
  {% for post in site.posts %}
    '{{ post.url }}',
  {% endfor %}
 
  // can be automated rather than manual entries
  "/assets/header.jpg",
  "/static/img/avatar.png",
  "/static/img/logo.png",
  "/static/css/main.css",
  "/static/css/bootstrap-material-design.min.css",
  "/static/css/bootstrap.min.css",
  "/about.md",
  "/blog.html"
];
 
self.addEventListener("install", function(e){
  self.skipWaiting();
  e.waitUntil(
    caches.open(staticCacheName).then(function(cache){
      return cache.addAll(filesToCache);
    })
  )
});

self.addEventListener("activate", function(e){
  e.waitUntil(
    caches.keys().then(function(cacheNames){
      return Promise.all(
        cacheNames.filter(function(cacheName){
          return cacheName.startsWith("gdad-s-river-static-")
            && cacheName != staticCacheName;
        }).map(function(cacheName){
          return cache.delete(cacheName);
        })
      )ß
    })
  )
});

self.addEventListener("fetch", function(e){
  e.respondWith(
     caches.match(e.request).then(function(response) {
       return response || fetch(e.request);
     })
   )
});

@@ -18,23 +18,15 @@
 ---%0A
- %0Aconst staticC
+%0A%0Avar c
 ache
@@ -36,184 +36,334 @@
 e = 
-%22gdad-s-river-static-v61%22;%0A %0Aconsole.log(%22installing service worker%22);%0A %0Aconst filesToCache = %5B%0A  %22/%22,%0A  %7B%25 for page in site.html_pages %25%7D%0A    '%7B%7B page.url %7D%7D',%0A  %7B%25 endfor %25%7D%0A
+'gdgpisa-cache-v1';%0Avar filesToCache = %5B%0A    // Stylesheets%0A    // Pages and assets%0A    %7B%25 for page in site.html_pages %25%7D%0A        %7B%25 if page.url contains 'projects' or page.url contains '404'   %25%7D%0A            %0A        %7B%25 else %25%7D%0A            '%7B%7B page.url %7D%7D',%0A        %7B%25 endif %25%7D%0A        %0A    %7B%25 endfor %25%7D%0A%0A    // Blog posts%0A  
   %7B%25
@@ -385,24 +385,28 @@
 te.posts %25%7D%0A
+    
     '%7B%7B post
@@ -415,16 +415,18 @@
 rl %7D%7D',%0A
+  
   %7B%25 end
@@ -734,17 +734,17 @@
 ner(
-%22
+'
 install
-%22
+'
 , fu
@@ -755,36 +755,25 @@
 on(e
-)%7B%0A  self.skipWaiting();%0A  e
+vent) %7B%0A    event
 .wai
@@ -772,32 +772,36 @@
 vent.waitUntil(%0A
+    
     caches.open(
@@ -800,23 +800,17 @@
 es.open(
-staticC
+c
 acheName
@@ -831,18 +831,25 @@
 n(cache)
+ 
 %7B%0A
+      
       re
@@ -877,24 +877,28 @@
 esToCache);%0A
+    
     %7D)%0A  )%0A%7D
@@ -886,33 +886,36 @@
 );%0A        %7D)%0A  
-)
+  );
 %0A%7D);%0A%0Aself.addEv
@@ -930,18 +930,15 @@
 ner(
-%22activate%22
+'fetch'
 , fu
@@ -949,122 +949,92 @@
 on(e
-)%7B%0A  e.waitUntil(%0A    caches.keys().then(function(cacheNames)%7B%0A      return Promise.all(%0A        cacheNames.filter
+vent) %7B%0A    event.respondWith(%0A        caches.match(event.request)%0A            .then
 (fun
@@ -1035,34 +1035,34 @@
 en(function(
-cacheNam
+respons
 e)
+ 
 %7B%0A          
@@ -1065,191 +1065,156 @@
     
-return cacheName.startsWith(%22gdad-s-river-static-%22)%0A            && cacheName != staticCacheName;%0A        %7D).map(function(cacheName)%7B%0A          return cache.delete(cacheName);%0A
+      if (response) %7B%0A                    console.log('%5B*%5D Serving cached: ' + event.request.url);%0A                    return response;%0A    
         
 %7D)%0A 
@@ -1213,152 +1213,91 @@
     
-%7D)
+    %7D%0A
 %0A      
-)%C3%9F%0A
     
-%7D)%0A  )%0A%7D);%0A%0Aself.addEventListener(%22fetch%22, function(e)%7B%0A  e.respondWith(%0A     caches.match(e.request).then(function(response) %7B%0A
+      console.log('%5B*%5D Fetching: ' + event.request.url);%0A         
     
@@ -1309,28 +1309,16 @@
 turn
- response %7C%7C
  fetch(e
 .req
@@ -1313,16 +1313,20 @@
  fetch(e
+vent
 .request
@@ -1337,15 +1337,33 @@
     
-%7D
+       %7D%0A        
 )%0A   
-)
+ );
 %0A%7D);

Update sw.js