Sha256: 51bb7eeedf5815dbbb753f651f740db172092fffd16ce7ddacc0e9e8e90b39d5

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

---
layout: compress
---
var cacheName = 'madhur-cache-v1';
var filesToCache = [
    {% for page in site.pages %}
        {% if page.url contains 'projects' or page.url contains '404'   %}
            
        {% else %}
            '{{ page.url }}',
        {% endif %}
        
    {% endfor %}

    {% for post in site.posts %}
        '{{ post.url }}',
    {% endfor %}

    {% for file in site.static_files %}
              '{{ file.path }}',
    {% 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);
            }
        )
    );
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-theme-mdui-0.2.1 sw.js