mapbox/mapbox-gl-js

When Cache API is not available, dont clone response for `cachePut`

Open

#8.416 geöffnet am 1. Juli 2019

Auf GitHub ansehen
 (2 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (2.203 Forks)batch import
bug :lady_beetle:good first issue

Repository-Metriken

Stars
 (10.532 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

The cacheGet method calls back to validateOrFetch with a null error if window.caches is not available. From what I can tell, this could happen when the Cache API is not available at all or if a page is served over http and the Cache API is not usable.

https://github.com/mapbox/mapbox-gl-js/blob/dd5dcd025a5465e85330ac564a27d3a4b60839dc/src/util/tile_request_cache.js#L72-L81

In this case validateOrFetch still calls clones the response and attempts to place it in the cache.

https://github.com/mapbox/mapbox-gl-js/blob/dd5dcd025a5465e85330ac564a27d3a4b60839dc/src/util/ajax.js#L127-L131

If it is known that window.caches is no available or usable, there is not need to clone the response or to load its contents:

https://github.com/mapbox/mapbox-gl-js/blob/dd5dcd025a5465e85330ac564a27d3a4b60839dc/src/util/ajax.js#L144-L152

Contributor Guide