operations icon indicating copy to clipboard operation
operations copied to clipboard

Dirty tiles cached for 7 days

Open nrenner opened this issue 1 year ago • 5 comments

Actual

When expired tiles can't be rerendered on-the-fly, the old (dirty) version is returned.

Currently, these dirty tiles get a Cache-Control: max-age=604800 and a corresponding Expires response header, that will cache them for seven days.

Expected

I would have expected dirty tiles to be cached for a very short time frame only, as described in #959:

Tiles which are known to be dirty when served are given a randomised expiry up to ModTileCacheDurationDirty which we have as 15 minutes.

Probably implemented in mod_tile.c and configured in tile.conf.erb?

Examples

Browser

Test case: z13 tile in a dense region with a very recent edit.

  1. Tile is clean. Last rendered at Tue Jun 08 10:38:36 2004. Last accessed at Sat Jun 08 10:38:36 2024
    • marked as expired (2004) before actually viewing the map in the browser
    • last rendered about two minutes ago, so expecting short cache duration for last modification
    • https://nidhogg.openstreetmap.org/13/4260/2729.png/status
  2. Browser tile requests returned after 2 seconds with Cache-Control: max-age=604800:
    screenshot-browser-requests
    • screenshot with custom response headers, called with network tab open and "Disable cache" activated
  3. Tile is clean. Last rendered at Sat Jun 08 10:40:49 2024. Last accessed at Sat Jun 08 10:40:49 2024
    • rendering took 16 seconds (Last rendered 10:40:49 - request started / Expires time 10:40:33),
      confirming that we indeed got dirty tiles
  • example headers (shortened):
    • General
      Request URL: https://tile.openstreetmap.org/13/4260/2729.png
      Status Code: 200 OK
      
    • Response Headers
      Age: 0
      Cache-Control: max-age=604800, stale-while-revalidate=604800, stale-if-error=604800
      Date: Sat, 08 Jun 2024 10:40:35 GMT
      Expires: Sat, 15 Jun 2024 10:40:33 GMT
      X-Cache: MISS
      X-Cache-Hits: 0
      X-Served-By: cache-muc13944-MUC
      X-Tilerender: nidhogg.openstreetmap.org
      

Script

Script requesting tile status and headers every minute, for an active HOT task with ongoing edits.

  • cache-control: max-age=604800 when expired
  • got dirty tile for those: etag stayed the same and only changed with next call,
    rendering times around 30 s and 21 s (next Last rendered - response date)

Example sequence:

Tile is clean. Last rendered at Fri Jun 07 12:46:34 2024. Last accessed at Fri Jun 07 12:47:25 2024
HTTP/2 200 
etag: "2a2d2b6d5ffc3ee6aaefcdad689469ab"
cache-control: max-age=12579, stale-while-revalidate=604800, stale-if-error=604800
x-tilerender: ysera.openstreetmap.org
date: Fri, 07 Jun 2024 15:29:10 GMT
x-served-by: cache-muc13959-MUC
x-cache: MISS

Tile is clean. Last rendered at Mon Jun 07 12:46:34 2004. Last accessed at Fri Jun 07 12:47:25 2024
HTTP/2 200 
etag: "2a2d2b6d5ffc3ee6aaefcdad689469ab"
cache-control: max-age=604800, stale-while-revalidate=604800, stale-if-error=604800
x-tilerender: ysera.openstreetmap.org
date: Fri, 07 Jun 2024 15:30:13 GMT
x-served-by: cache-muc13978-MUC
x-cache: MISS

Tile is clean. Last rendered at Fri Jun 07 15:30:43 2024. Last accessed at Fri Jun 07 15:30:43 2024
HTTP/2 200 
etag: "cf80c42b67a6618d80f8fbb3b6ac0fce"
cache-control: max-age=6991, stale-while-revalidate=604800, stale-if-error=604800
x-tilerender: ysera.openstreetmap.org
date: Fri, 07 Jun 2024 15:31:13 GMT
x-served-by: cache-muc13945-MUC
x-cache: MISS

Tile is clean. Last rendered at Mon Jun 07 15:30:43 2004. Last accessed at Fri Jun 07 15:31:13 2024
HTTP/2 200 
etag: "cf80c42b67a6618d80f8fbb3b6ac0fce"
cache-control: max-age=604800, stale-while-revalidate=604800, stale-if-error=604800
x-tilerender: ysera.openstreetmap.org
date: Fri, 07 Jun 2024 15:32:16 GMT
x-served-by: cache-muc13977-MUC
x-cache: MISS

Tile is clean. Last rendered at Fri Jun 07 15:32:37 2024. Last accessed at Fri Jun 07 15:32:37 2024
HTTP/2 200 
etag: "04a889c787d54d0f7bbfe0c190136d38"
cache-control: max-age=5173, stale-while-revalidate=604800, stale-if-error=604800
x-tilerender: ysera.openstreetmap.org
date: Fri, 07 Jun 2024 15:33:17 GMT
x-served-by: cache-muc13928-MUC
x-cache: MISS

nrenner avatar Jun 09 '24 14:06 nrenner