mapbox / mapbox-gl-js

Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL
https://docs.mapbox.com/mapbox-gl-js/
Other
11.04k stars 2.21k forks source link

Configurable tile cache size #8967

Open Plantain opened 4 years ago

Plantain commented 4 years ago

Recently a tilecache has been added to Mapbox GL JS using Cache API (https://github.com/mapbox/mapbox-gl-js/pull/8363)

The size seems to be set at 50MB, but a larger cache would improve performance on machines with more storage available. https://github.com/mapbox/mapbox-gl-js/blob/30db469efec189f100efa8ca15416f2127c267a0/src/util/tile_request_cache.js#L9

Can this be piped through to a property in mapboxgl.Map like: new mapboxgl.Map({ cacheSize: 10010241024 }) ?

jonathanflack commented 4 years ago

It would be nice to have finer granularity control for this, down to the individual pbf. There are very real production reasons why administrators would want to focus cache allocation around certain resource intensive datasets, rather than a one-size-fits-all solution.

ryanhamley commented 4 years ago

@ansis i'm not super familiar with the way we implemented the cache api. what are your thoughts on the feasibility of this?

jonathanflack commented 4 years ago

I'll note that this discussion is not a new one: https://github.com/mapbox/mapbox-gl-js/pull/8363#pullrequestreview-251234313

Plantain commented 4 years ago

Having control of this on a source-by-source basis would also be great - currently I already implement a cache this for my own source to allow offline/PWA capabilities.

Perhaps more useful would be instead of: mapboxgl.Map({ cacheSize: 100 1024 1024 }) but rather: map.addSource("source", {cacheSize: 100 1024 1024})

Tiles could be in an individual cache as per their source (instead of mapbox-tiles, {source}-tiles)

kkaefer commented 4 years ago

We could use the StorageEstimate API if available to increase the storage size.

bennlich commented 3 years ago

@Plantain would love to see how you've implemented this! Currently struggling to expand the cache.