Skip to content

Commit

Permalink
Change cache strategy for map tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
russss committed Apr 4, 2024
1 parent a61de32 commit 09b128a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions web/src/sw.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createHandlerBoundToURL, precacheAndRoute, cleanupOutdatedCaches } from 'workbox-precaching'
import { clientsClaim } from 'workbox-core'
import { StaleWhileRevalidate } from 'workbox-strategies'
import { StaleWhileRevalidate, NetworkFirst } from 'workbox-strategies'
import { registerRoute } from 'workbox-routing'

declare let self: ServiceWorkerGlobalScope
Expand All @@ -14,7 +14,10 @@ function register(match_url: string, strategy: any) {
precacheAndRoute(self.__WB_MANIFEST)

register('capabilities/buildmap', new StaleWhileRevalidate())
register('maps', new StaleWhileRevalidate())

// Cache map tiles using NetworkFirst for the moment - may be worth switching
// to StaleWhileRevalidate closer to the event.
register('maps', new NetworkFirst())

try {
// Only catch requests to the root URL (a regex doesn't do this).
Expand Down

0 comments on commit 09b128a

Please sign in to comment.