From ac7a957143706228afcd9a84b374d7237d42e7db Mon Sep 17 00:00:00 2001 From: Petr Sloup Date: Fri, 19 Apr 2024 11:49:58 +0200 Subject: [PATCH 1/2] RD-254 Fix for the client-side caching breaking GeoJSON (and video) sources --- src/caching.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/caching.ts b/src/caching.ts index fe98022..0ac0988 100644 --- a/src/caching.ts +++ b/src/caching.ts @@ -23,7 +23,7 @@ export function localCacheTransformRequest( config.session && reqUrl.host === defaults.maptilerApiHost ) { - if (resourceType == "Source") { + if (resourceType == "Source" && reqUrl.href.includes("tiles.json")) { return reqUrl.href.replace( "https://", `${LOCAL_CACHE_PROTOCOL_SOURCE}://`, @@ -74,9 +74,11 @@ export function registerLocalCacheProtocol() { const response = await fetch(params.url, requestInit); const json = await response.json(); - // move `Last-Modified` to query so it propagates to tile URLs - json.tiles[0] += - "&last-modified=" + response.headers.get("Last-Modified"); + if (json.tiles && json.tiles.length > 0) { + // move `Last-Modified` to query so it propagates to tile URLs + json.tiles[0] += + "&last-modified=" + response.headers.get("Last-Modified"); + } return { data: json, From 99e8e116343157597744e90ae9cf14a19646d917 Mon Sep 17 00:00:00 2001 From: Petr Sloup Date: Fri, 19 Apr 2024 11:53:49 +0200 Subject: [PATCH 2/2] Add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61e6523..1784efc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## DEVEL ### New Features ### Bug Fixes +- Fix for the client-side caching breaking GeoJSON sources [#82](https://github.com/maptiler/maptiler-sdk-js/pull/82) ### Others ## 2.0.1