OfflineTilePyramidRegionDefinition caching style url
Platform: Android Mapbox SDK version: 4.2.0-beta.5@aar
So what's happening is that I have hosted style definitions in my server and creating offline regions for them seem to be caching the content of the http request and therefore always downloading the same tiles for those urls.
Steps to trigger behavior
- Create an offline region definition with a custom url
- Download region
- Create a new offline region definition with the same url but the contents of the style definition hosted in that url are different from the first created.
- Download region.
Expected behavior
New tiles defined by the url are downloaded.
Actual behavior
It seems to have the contents of the url cached so it does not download tiles defined in the new style.
I am aware that caching is a good practice but I think in this case it should not cache the contents of the style urls.
I am also thinking what would happen if styles hosted for mapbox urls (mapbox://styles/mapbox/streets-v9, etc.) change, I think the same problem will occur.
I hope I've explained myself, if not please let me know. Thanks.
This is the intended behavior of offline regions (and of URLs in general). If you have different resources, they must have different URLs.
Updates to Mapbox styles (and in general, updates to any resource) are handled through use of the standard HTTP headers for caching, Expires, Cache-Control, and Etag. The offline implementation will refresh resources according to the schedule established by these headers.
Hi @jfirebaugh thanks for the reply, I took a look into the mbgl-offline.db database and I don't understand why for the resource with the same url it doesn't update its etag column when the etag of the http response is different. Isn't this supposed to happen when it changes and you request the same url?
It does update the etag: https://github.com/mapbox/mapbox-gl-native/blob/62ea1f21858c69f6921c775ba7a3de201f0514d8/platform/default/mbgl/storage/offline_database.cpp#L290-L290