# HG changeset patch # User Tero Marttila # Date 1412380004 -10800 # Node ID e7822b0be417e95e9505d7d5975d0fc7166dad5b # Parent 73380dd6a816ec4ab80151e0e2b24034408446d2 pngtile.tile: change to providing a short Cache-Control: max-age for unknown-url-time images diff -r 73380dd6a816 -r e7822b0be417 pngtile/tile.py --- a/pngtile/tile.py Sat Oct 04 02:19:43 2014 +0300 +++ b/pngtile/tile.py Sat Oct 04 02:46:44 2014 +0300 @@ -46,6 +46,9 @@ return scale(val, zoom) - dim / 2 class TileApplication (pngtile.application.PNGTileApplication): + # age in seconds for caching an unknown-mtime image for revalidates + MIN_AGE = 10 # 10 seconds + # age in seconds for caching a known-mtime image MAX_AGE = 7 * 24 * 60 * 60 # 1 week @@ -178,7 +181,7 @@ if not ttime: # cached item may change while url stays the same - response.headers['Cache-Control'] = 'must-revalidate' + response.headers['Cache-Control'] = 'max-age={min_age:d}'.format(min_age=self.MIN_AGE) elif ttime == mtime: # url will change if content changes