Skip to Content
APIConfigurationInterface: MapTileCacheConfig

Interface: MapTileCacheConfig

Configuration options for map tile caching. Allows controlling how map tiles are cached in memory and persisted via service worker.

Example

const tileCacheConfig: MapTileCacheConfig = { enabled: true, maxTiles: 500, ttlMs: 60 * 60 * 1000, // 1 hour persistToServiceWorker: true, preloadAdjacentZooms: false, maxConcurrentTileFetches: 6, }

Properties

enabled?

optional enabled: boolean;

Enable tile caching When false, tiles are fetched directly without caching

Default

true

maxConcurrentTileFetches?

optional maxConcurrentTileFetches: number;

Max concurrent HTTP requests for vector tiles when persistToServiceWorker is true (custom cached-tile:// protocol). Lower values reduce burst traffic to the tile CDN, which helps with WAF / rate limiting on shared hosting.

Default

6

maxTiles?

optional maxTiles: number;

Maximum number of tiles to keep in MapLibre’s memory cache Higher values use more memory but improve performance for panning/zooming. Values above an internal hard cap are clamped to protect memory and to avoid extreme tile retention that can amplify traffic to the tile CDN.

Default

400

persistToServiceWorker?

optional persistToServiceWorker: boolean;

Enable service worker persistence for offline tile access When true, tiles are cached via the cached-tile:// protocol

Default

true

preloadAdjacentZooms?

optional preloadAdjacentZooms: boolean;

Preload tiles for adjacent zoom levels Improves zoom transitions but increases initial load time and bandwidth. Reserved for future MapLibre integration; currently does not change runtime behavior.

Default

false

ttlMs?

optional ttlMs: number;

Time-to-live in milliseconds for cached tiles After this time, tiles will be re-fetched on next request

Default

1800000 (30 minutes)
Last updated on