osmtilecache.cgi: Simple tile cache solution

As tile caching was mentioned in another thread I thought maybe there could be some interest in a small project that I’ve developed some years ago:


This handles several tasks at once for “small volume” tile caching:

  • Works on “regular webhosting” without full server access.
  • Allows to specify the region you want to host to limit the amount of space used by the cache service
  • All you need is CGI support and Perl (I’ve chosen Perl as it is still more common to find this provided than Python)
  • Probably only works on Linux hosts and I don’t plan to change this. Heavily relies on file locking for cross process syncing.


  • Dynamically downloads missing tiles
  • Serves tiles from cache if they are not “outdated” (two days by default)
  • If a tile is “outdated” it is still served from cache, but noted in a “pending update” list
  • A cron job triggers tile update from time to time. This is to speed up tile serving. Tiles are always served from cache and cache update is a decoupled process.
  • The script contains a PNG checksum check to prevent corrupt files from getting into the cache

In theory all you need is place the file, edit the parameters in the header (region you want to cover) and configure your map accordingly.

I have this in use here: https://karte.hgv-steinfeld.de/