Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache tiles in ready-to-serve encoding #1112

Open
nyurik opened this issue Dec 31, 2023 · 0 comments
Open

Cache tiles in ready-to-serve encoding #1112

nyurik opened this issue Dec 31, 2023 · 0 comments
Labels
enhancement serving Related to web serving component

Comments

@nyurik
Copy link
Member

nyurik commented Dec 31, 2023

Current State

Since v0.13, Martin caches tile data as it comes back from the individual sources (PG/mbtiles/pmtiles). This means that if mbtiles contains gziped-compressed MVT tiles, cache will contain that tile, and no re-compression will be needed. If PostgreSQL generates an uncompressed tile, the tile will be cached, but each tile request has to gzip that tile anew. This is the usual case unless user has a custom PG function that uses a gzip extension to compress the tile on the database side.

Goals

  • Martin should cache data after compressing it
  • Martin could re-compress responses in Brotli even if the storage format is gzip.

Solutions

  • generic solution - either as a custom function or a proper Actix "filter", capture the entire request (URL path + query + accept-encoding), and cache/send back the most optimal response
  • per end-point (tiles vs tilejson vs sprites ...) a more custom implementation that takes into account the specifics of each endpoint. This might be easier to implement, but also means that each endpoint will have to write a bit of extra code.

Brotli vs Gzip

Per Brotli wiki, it offers significantly better rate of compression and decompression performance than gzip. Desktop Chrome current default Accept-Encoding is gzip, deflate, br (tested on Linux with latest Chrome). Reading Quality_values seem to indicate that the order of the values is irrelevant as long as they have the same "q" value (default is 1), which means that the "gzip, deflate, br" string indicates it is OK to send back Brotli, even though it is 3rd in the list. Obviously if br is not in the list, it will have to be gzip or identity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement serving Related to web serving component
Projects
None yet
Development

No branches or pull requests

1 participant