Judge fetched tiles apart from kept ones; share Esri's request slots

Review round 2: with part of a map's tiles on disk, the placeholder
check saw several pictures and let a provider's placeholder through,
drew it and kept it for 30 days. The tiles fetched now are judged on
their own: two or more that are all one picture matching no kept tile
are a placeholder, and the map fails whole (nothing drawn or kept, the
poster served for five minutes). A real uniform tile, such as open sea,
matches one kept before and passes.

From its notes: the request slots are per tile host, so the satellite
and both grey canvases share Esri's six; a weak If-None-Match matches;
the README says a poster is kept once its map or photo came.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
This commit is contained in:
2026-11-27 10:42:48 +01:00
parent e6701fcd27
commit 670ecc0162
3 changed files with 24 additions and 13 deletions
+1 -1
View File
@@ -108,7 +108,7 @@ def poster_response(request: Request, png: bytes, kept: bool) -> Response:
return FastAPIResponse(content=png, media_type="image/png", headers={"Cache-Control": "public, max-age=300"})
etag = '"' + hashlib.sha256(png).hexdigest()[:32] + '"'
headers = {"Cache-Control": "public, max-age=86400", "ETag": etag}
if etag in [tag.strip() for tag in request.headers.get("if-none-match", "").split(",")]:
if etag in [tag.strip().removeprefix("W/") for tag in request.headers.get("if-none-match", "").split(",")]:
return Response(status_code=304, headers=headers)
return FastAPIResponse(content=png, media_type="image/png", headers=headers)