protomaps / go-pmtiles

Single-file executable tool for working with PMTiles archives
BSD 3-Clause "New" or "Revised" License
350 stars 48 forks source link

Set etag on pmtiles serve responses #137

Closed msbarry closed 6 months ago

msbarry commented 6 months ago

Set etag on tile, metadata, and tilejson responses. By default it uses the etag from the archive but you can opt into computing an etag per-resource with --tile-etag flag. The default archive etag behavior minimizes runtime overhead and is guaranteed to return a new etag when tile contents changes, but also ends up changing the etag (and purging intermediate caches) when the archive changes but an individual tile is the same between old and new archive.

This also implements If-Match and If-None-Match header handling by using go's built-in http.ServeContent utility. As a side effect this also means that pmtiles serve now supports range requests within individual tiles.