Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using Leaflet and infostream's fork of mbtiles-php to serve MBTiles stored on my server. I'm using a Leaflet layer group (and a layer control) to serve two MBTiles files. When I toggle between the two layers using the layer control at the same zoom level, my local cache is rebuilt rather than reusing the existing tiles.

In the Leaflet layer group example, toggling between the two layers reuses the locally cached tiles, although I assume that the example tileset is not in MBTiles format. In the examples that I've seen through MapBox (using MBTiles but with the ModestMaps library), the locally cached tiles are also being reused.

My information on reuse of caching come from clearing the cache (using Chrome) and then examining the developer tools network tab to see the tiles being built (or not built).

Am I missing some customization of mbtiles-php that would allow reuse of tiles? I've seen reference to mbutils, but I'd prefer to keep the tiles in MBTiles format.

share|improve this question
up vote 1 down vote accepted

I was able to fix this in mbtiles-php tileserver.php by adding this call:

header('Cache-Control: max-age=3600');

when serving out the image tiles. I have no idea of the wisdom of this, although I did notice that in both the Leaflet and Mapbox examples that I point to above, they have similar 'Cache-Control' HTTP headers on the PNG tiles they serve. Here is the relevant diff:

>         header('Cache-Control: max-age=3600');
>         header('Cache-Control: max-age=3600');

Please let me know if this is a bad idea.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.