Skip to content

Commit

Permalink
Serviceworker tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
russss committed Mar 4, 2024
1 parent 588e2f4 commit 55f7947
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
2 changes: 0 additions & 2 deletions web/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class EventMap {
marker?: Marker

init() {
registerSW({ immediate: true })

const layers_enabled = ['Villages']
this.layer_switcher = new LayerSwitcher(this.layers, layers_enabled)

Expand Down
9 changes: 2 additions & 7 deletions web/src/sw.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createHandlerBoundToURL, precacheAndRoute, cleanupOutdatedCaches } from 'workbox-precaching'
import { clientsClaim } from 'workbox-core'
import { StaleWhileRevalidate } from 'workbox-strategies'
import { NavigationRoute, registerRoute } from 'workbox-routing'
import { registerRoute } from 'workbox-routing'

declare let self: ServiceWorkerGlobalScope

Expand All @@ -17,14 +17,9 @@ register('capabilities/buildmap', new StaleWhileRevalidate())
register('maps', new StaleWhileRevalidate())

try {
registerRoute(
new NavigationRoute(createHandlerBoundToURL('index.html'), {
denylist: [/\/stats/, /\/noc/, /\/power/],
})
)
registerRoute(/\/$/, createHandlerBoundToURL('index.html'))
} catch (e) {
// This fails in dev as index.html is not in the manifest.
console.error(e)
}

cleanupOutdatedCaches()
Expand Down

0 comments on commit 55f7947

Please sign in to comment.