diff --git a/src/service-worker.js b/src/service-worker.js index 1b04819c7a0f9e3a915b944b3b5e3d53954d0d27..7dd25fb94ea383cea55ef57465533c7422199f08 100644 --- a/src/service-worker.js +++ b/src/service-worker.js @@ -29,10 +29,15 @@ if (workbox) { new RegExp('.*/api/.*'), new workbox.strategies.NetworkFirst({ cacheName: 'api', + plugins: [ + new workbox.cacheableResponse.Plugin({ + statuses: [0, 200], + }), + ], }) ); workbox.routing.registerRoute( - /^https:\/\/c\.tile\.openstreetmap\.fr/, + /^https:\/\/[a-zA-Z]\.tile\.openstreetmap\.fr/, new workbox.strategies.CacheFirst({ cacheName: 'osm', plugins: [ @@ -46,6 +51,21 @@ if (workbox) { ], }) ); + workbox.routing.registerRoute( + /^https:\/\/osm\.geo2france\.fr\/mapcache/, + new workbox.strategies.CacheFirst({ + cacheName: 'mapcache', + plugins: [ + new workbox.cacheableResponse.Plugin({ + statuses: [0, 200], + }), + new workbox.expiration.Plugin({ + maxAgeSeconds: 60 * 60 * 24 * 365, + // maxEntries: 30, pour limiter le nombre d'entrée dans le cache + }), + ], + }) + ); }