Skip to content

Conversation

@keichan34
Copy link

This is more of a first draft than a completed PR, but I wanted some feedback on the implementation before cleaning it up and updating documentation. I'm especially interested in whether something like this belongs in the repository at all, and what kind of documentation / configuration would be appropriate for a feature of this kind.

Motivation: In the docs, it's recommended to reset the cache by resetting the cache for the whole domain, which can be a bit tedious sometimes. This implementation uses the ETag of the R2 object as a ?v=... query string on the tile URLs, so uploading a new PMTiles file will trigger changing the URL in the tiles.json endpoint, which won't be in the cache. I set the default cache-control to something short like 30 seconds in my deploy.

I've set the Cache-Control of the tiles.json endpoint to the environment variable to match the original behavior, but it might make sense to split it out to a different variable??

@bdon
Copy link
Member

bdon commented Apr 10, 2025

I'm especially interested in whether something like this belongs in the repository at all, and what kind of documentation / configuration would be appropriate for a feature of this kind.

This is an interesting approach, but I don't think it should be the default behavior. Currently, TileJSON is a simple descriptor over the param-less ZXY endpoint. This would instead make the behavior different between using TileJSON and raw ZXY endpoint, which would be surprising. There's plenty of other clients that don't use TileJSON (MapLibre may be the only one) and they wouldn't benefit from this. Even with MapLibre, hardcoding the ZXY tile endpoint in the style is often preferred to TileJSON since you can eliminate one network roundtrip on initial map load.

I think this could be really useful though for certain situations, since the entire Cloudflare implementation is ~200LOC maybe it could be fine to maintain a custom Workers variant of the default code? We could make it easier by moving the shared module into the pmtiles main npm package for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants