shorter etags
@@ -48,6 +48,7 @@ def build_access_cache_key(access_permissions: set):
def build_tile_etag(level_id, zoom, x, y, base_cache_key, access_cache_key, tile_secret):
- return '"' + base64.b64encode(hashlib.sha256(
- ('%d-%d-%d-%d:%s:%s:%s' % (level_id, zoom, x, y, base_cache_key, access_cache_key, tile_secret)).encode()
- ).digest()).decode() + '"'
+ # we want a short etag so HTTP 304 responses are tiny
+ return '"' + base64.b85encode(hashlib.sha256(
+ ('%d-%d-%d-%d:%s:%s:%s' % (level_id, zoom, x, y, base_cache_key, access_cache_key, tile_secret[:26])).encode()
+ ).digest()).decode()[:16] + '"'
