Dynamic Cache Attempt

Bump to testing
This commit is contained in:
Fred Boniface 2023-05-04 10:21:42 +01:00
parent 8335365bbf
commit 97c940cc44
2 changed files with 38 additions and 31 deletions

View File

@ -1,5 +1,5 @@
/* All Page Init */
const version = '2.0.0-rc'
const version = '2.0.0-testing'
/* Feature Detectors */

67
sw.js
View File

@ -1,40 +1,13 @@
/* Service Worker */
const appVersion = 'PIS-DEV-0105002'
const appVersion = '2.0.0-test'
const cacheName = `owlboard-${appVersion}`
const cacheIDs = [cacheName]
const cacheFiles = [
'/404.html',
'/auth.html',
'/board.html',
'/conn-err.html',
'/help.html',
'/',
'/issue.html',
'/find-code.html',
'/settings.html',
'/pis.html',
'/manifest.json',
const staticCache = [
'/styles/fonts/firamono/firamono-500.woff2',
'/styles/fonts/firamono/firamono-regular.woff2',
'/styles/fonts/urwgothic/urwgothic.woff2',
'/styles/fonts/urwgothic/urwgothicDemi.woff2',
'/styles/board.css',
'/styles/find-code.css',
'/styles/help.css',
'/styles/issue.css',
'/styles/main.css',
'/styles/settings.css',
'/styles/pis.css',
'/js/find-code.js',
'/js/index.js',
'/js/issue.js',
'/js/lib.board.js',
'/js/lib.main.js',
'/js/auth.js',
'/js/settings.js',
'/js/simple-board.js',
'/js/pis.js',
'/images/icon.svg',
'/images/logo/wide_logo.svg',
'/images/logo/mono-logo.svg',
@ -50,6 +23,40 @@ const cacheFiles = [
'/images/nre/nre-powered_400w.webp',
'/images/nre/nre-powered_400w.jxl'
]
const dynamicCache = [
'/404.html',
'/auth.html',
'/board.html',
'/conn-err.html',
'/help.html',
'/',
'/issue.html',
'/find-code.html',
'/settings.html',
'/pis.html',
'/manifest.json',
'/styles/board.css',
'/styles/find-code.css',
'/styles/help.css',
'/styles/issue.css',
'/styles/main.css',
'/styles/settings.css',
'/styles/pis.css',
'/js/find-code.js',
'/js/index.js',
'/js/issue.js',
'/js/lib.board.js',
'/js/lib.main.js',
'/js/auth.js',
'/js/settings.js',
'/js/simple-board.js',
'/js/pis.js'
]
for(let i = 0; i < dynamicCache.length; i++) {
let item = dynamicCache[i] + `?${appVersion}`
staticCache.push(item)
}
self.addEventListener('install', (e) => {
console.log('[Service Worker] Install')
@ -57,7 +64,7 @@ self.addEventListener('install', (e) => {
(async () => {
const cache = await caches.open(cacheName)
console.log('[Service Worker] Caching app data')
await cache.addAll(cacheFiles)
await cache.addAll(staticCache)
})()
)
})