equal
deleted
inserted
replaced
44 """ |
44 """ |
45 |
45 |
46 return scale(val, zoom) - dim / 2 |
46 return scale(val, zoom) - dim / 2 |
47 |
47 |
48 class TileApplication (pngtile.application.PNGTileApplication): |
48 class TileApplication (pngtile.application.PNGTileApplication): |
|
49 # age in seconds for caching an unknown-mtime image for revalidates |
|
50 MIN_AGE = 10 # 10 seconds |
|
51 |
49 # age in seconds for caching a known-mtime image |
52 # age in seconds for caching a known-mtime image |
50 MAX_AGE = 7 * 24 * 60 * 60 # 1 week |
53 MAX_AGE = 7 * 24 * 60 * 60 # 1 week |
51 |
54 |
52 def __init__ (self, image_server, **opts): |
55 def __init__ (self, image_server, **opts): |
53 """ |
56 """ |
176 response = Response(png, content_type='image/png') |
179 response = Response(png, content_type='image/png') |
177 response.last_modified = mtime |
180 response.last_modified = mtime |
178 |
181 |
179 if not ttime: |
182 if not ttime: |
180 # cached item may change while url stays the same |
183 # cached item may change while url stays the same |
181 response.headers['Cache-Control'] = 'must-revalidate' |
184 response.headers['Cache-Control'] = 'max-age={min_age:d}'.format(min_age=self.MIN_AGE) |
182 |
185 |
183 elif ttime == mtime: |
186 elif ttime == mtime: |
184 # url will change if content changes |
187 # url will change if content changes |
185 response.headers['Cache-Control'] = 'max-age={max_age:d}'.format(max_age=self.MAX_AGE) |
188 response.headers['Cache-Control'] = 'max-age={max_age:d}'.format(max_age=self.MAX_AGE) |
186 |
189 |