pngtile.tile: change to providing a short Cache-Control: max-age for unknown-url-time images
authorTero Marttila <terom@qmsk.net>
Sat, 04 Oct 2014 02:46:44 +0300
changeset 173 e7822b0be417
parent 172 73380dd6a816
child 174 58c9e2de0dd4
pngtile.tile: change to providing a short Cache-Control: max-age for unknown-url-time images
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