I'm running an OSM tile server with the default stack (mapnik, tirex, mod_tile, apache). Since I need only specific areas, I usually pre-render all tiles. Now I want to rebuild the Postgres DB bcs of a schema change (in order to satisfy specific style requirements). How can I avoid tiles requests to fail during that time because of mod_tile cache expiration policy? I'm using the default mod_tile config and don't yet know much about it.

4 Answers 4


I think I found a better way then the proposed ones (better because easier and less invasive): If the file /var/lib/mod_tile/planet-import-complete exists, its modification timestamp determines if cached tiles can expire or not. If the file timestamp is older then the cached tiles, they will not be regenerated.

According to this posting by Frederik mod_tile assumes the DB data is 3 days old if this file is missing.

Hint: The touch command has a parameter -t for manually setting the timestamp (in my case into the past)

I found out reading http://switch2osm.org/serving-tiles/building-a-tile-server-from-packages/


If your server has enough disk space, then rebuild your database in a database with a different name. After your DB rebuild is finished you can switch the databases in the config.

  • > If your server has enough disk space... The answer is yes and no. There is enough disk space, however not on the SSDs which currently hold the DB. I would prefer a solution where tile serving works without DB for a short time (using pre-rendered tiles). Still, it should be a viable way - with some admin overhead, I'll try it out. Thx.
    – didi_bcg
    Dec 18, 2014 at 10:25
  • @didi_bcg ... i think about a solution with 1. set the mod_tile expires header to a month in the future, 2. kill renderd and remove the db connection and start renderd again, 3. restart apache and see if it works - but I have currently no server to test it :-/
    – OkieOth
    Dec 18, 2014 at 10:45
  • @didi_bcg the solution described earlier works on my machine .. but it's to much hacked :-D. What about to prerender your tiles again with the mapnik tools. This will save your files as png in the file system and you can provide it temporarily with your normal apache (without mod_tile). After you have change your database you can switch back to mod_tile.
    – OkieOth
    Dec 18, 2014 at 11:03

Have a look at the following sites:



Another option is to touch all files in the cache to a recent date & time (for example januari 12 2015 0:00u):

find /var/lib/mod_tile/[tiledir]/ -type f -exec touch -t 201501120000 {} \;

I moved the tiles to the future: find /var/lib/mod_tile/default/ -type f -exec touch -t 202201120000 {} \; (default being the directory from linuxbabe's implementation)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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