maptiler / tileserver-gl

Vector and raster maps with GL styles. Server side rendering by MapLibre GL Native. Map tile server for MapLibre GL JS, Android, iOS, Leaflet, OpenLayers, GIS via WMTS, etc.
https://tileserver.readthedocs.io/en/latest/
Other
2.23k stars 638 forks source link

Cache-Control #543

Closed georgbachmann closed 3 years ago

georgbachmann commented 3 years ago

Just a very simple quick question...

We just noticed that tileserver-gl responses do not include a Cache-Control header. Is it possible to add some using tileserver-gl or should we do so in our varnish cache?

mnutt commented 3 years ago

You could set it in tileserver-gl but it would involve modifying the code and maintaining a fork; the varnish cache config would probably be an easier place to set it.

georgbachmann commented 3 years ago

Yep... we solved our problem using the varnish cache headers! Thanks for your answer though! Cheers

2803media commented 1 year ago

hi @georgbachmann could you please share your varnish config i'm stuck with it right now in my docker config? Tx

georgbachmann commented 1 year ago

@2803media we ended up using ATS (appache traffic server) for our caching, as we could not invalidate individual tiles using varnish (unlong we pay a looooooot per year) If it's still relevant to you with ATS, i could ask the person who did it how... I don't know much about that kind of black-magic :)

mnutt commented 1 year ago

I should probably have asked more about the use case, whether you're trying to get varnish to cache tiles for a certain amount of time, or browsers, or both. If you're trying to send headers to the browser to instruct it to cache for one day, you could use something like:

sub vcl_deliver {
   set resp.http.Cache-Control = "public, max-age=86400";
}

If you're trying to cause varnish to hold the tiles in its cache for one day, you might use something like:

sub vcl_backend_response {
    set beresp.ttl = 24h;
}
2803media commented 1 year ago

@2803media we ended up using ATS (appache traffic server) for our caching, as we could not invalidate individual tiles using varnish (unlong we pay a looooooot per year) If it's still relevant to you with ATS, i could ask the person who did it how... I don't know much about that kind of black-magic :)

Thanks for your reply and you are happy with the performance with ATS (which I never try ;)), if you have more information on the setup I will be happy to try it!