Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
add comment

1 Answer

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:

244a245
>         header('Cache-Control: max-age=3600');
259a261
>         header('Cache-Control: max-age=3600');

Please let me know if this is a bad idea.

share|improve this answer
add comment

Your Answer

 
discard

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.