From 5c119e903d616cf76f4f845ba8f7aa726a6bd4f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Tue, 25 Apr 2023 10:25:09 +0200 Subject: [PATCH] increment cache version for service-worker.js (#1644) * increment cache version * add serviceworker incrementer on make bundle --- Makefile | 3 +++ lnbits/core/static/js/service-worker.js | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b92e87e9e..9cf1bd140 100644 --- a/Makefile +++ b/Makefile @@ -86,3 +86,6 @@ bundle: npm run vendor_minify_css npm run vendor_bundle_js npm run vendor_minify_js + # increment serviceworker version + sed -i -e "s/CACHE_VERSION =.*/CACHE_VERSION = $$(awk '/CACHE_VERSION =/ { print 1+$$4 }' lnbits/core/static/js/service-worker.js)/" \ + lnbits/core/static/js/service-worker.js diff --git a/lnbits/core/static/js/service-worker.js b/lnbits/core/static/js/service-worker.js index 98ae497ec..44f11b131 100644 --- a/lnbits/core/static/js/service-worker.js +++ b/lnbits/core/static/js/service-worker.js @@ -1,5 +1,6 @@ -// the cache version gets updated every time there is a new deployment -const CACHE_VERSION = 1 +// update cache version every time there is a new deployment +// so the service worker reinitializes the cache +const CACHE_VERSION = 2 const CURRENT_CACHE = `lnbits-${CACHE_VERSION}-` const getApiKey = request => {