From 01076278493fd722fc658e7d51b49267c9c37dff Mon Sep 17 00:00:00 2001 From: navanchauhan Date: Mon, 17 Oct 2022 23:58:20 -0600 Subject: add service worker --- static/pwabuilder-sw.js | 18 ++++++++++++++++++ templates/document_details.html | 6 +++++- templates/home.html | 5 +++++ templates/search_results.html | 5 +++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 static/pwabuilder-sw.js diff --git a/static/pwabuilder-sw.js b/static/pwabuilder-sw.js new file mode 100644 index 0000000..860da8c --- /dev/null +++ b/static/pwabuilder-sw.js @@ -0,0 +1,18 @@ +// This is the "Offline copy of pages" service worker + +const CACHE = "pwabuilder-offline"; + +importScripts('https://storage.googleapis.com/workbox-cdn/releases/5.1.2/workbox-sw.js'); + +self.addEventListener("message", (event) => { + if (event.data && event.data.type === "SKIP_WAITING") { + self.skipWaiting(); + } +}); + +workbox.routing.registerRoute( + new RegExp('/*'), + new workbox.strategies.StaleWhileRevalidate({ + cacheName: CACHE + }) +); \ No newline at end of file diff --git a/templates/document_details.html b/templates/document_details.html index 9e98879..e387d1b 100644 --- a/templates/document_details.html +++ b/templates/document_details.html @@ -91,6 +91,10 @@ - + \ No newline at end of file diff --git a/templates/home.html b/templates/home.html index 31de085..5b5cd6b 100644 --- a/templates/home.html +++ b/templates/home.html @@ -22,5 +22,10 @@ + \ No newline at end of file diff --git a/templates/search_results.html b/templates/search_results.html index 28b7b24..bb544be 100644 --- a/templates/search_results.html +++ b/templates/search_results.html @@ -94,5 +94,10 @@ {{ end }} + \ No newline at end of file -- cgit v1.2.3