diff --git a/static/service-worker.js b/static/service-worker.js index 7334575..524322d 100644 --- a/static/service-worker.js +++ b/static/service-worker.js @@ -1,3 +1,35 @@ +const CACHE_NAME = 'ktvmanager-cache-v1'; +const urlsToCache = [ + '/', + '/static/styles.css', + '/static/favicon.ico', + '/static/favicon-96x96.png', + '/static/favicon.svg', + '/static/apple-touch-icon.png', + '/static/web-app-manifest-192x192.png', + '/static/web-app-manifest-512x512.png', + '/static/site.webmanifest' +]; + +self.addEventListener('install', function(event) { + event.waitUntil( + caches.open(CACHE_NAME) + .then(function(cache) { + console.log('Opened cache'); + return cache.addAll(urlsToCache); + }) + ); +}); + self.addEventListener('fetch', function(event) { - // empty + event.respondWith( + caches.match(event.request) + .then(function(response) { + if (response) { + return response; + } + return fetch(event.request); + } + ) + ); }); \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index 261de8f..7d897ce 100644 --- a/templates/base.html +++ b/templates/base.html @@ -53,5 +53,10 @@ {% block scripts %}{% endblock %} + \ No newline at end of file diff --git a/templates/home.html b/templates/home.html index 01b830f..8755fbc 100644 --- a/templates/home.html +++ b/templates/home.html @@ -53,9 +53,4 @@ {% endblock %} {% block scripts %} - {% endblock %}