Topic: Clear cache if map updated

Hey guys!

Thank you for your work on this plugin!

I have a question - is it possible to somehow check that the map style has been updated and when the app starts, clear the cache so that a new map is loaded. We use the Mapbox map and when the style is updated, we still see some part (cached part) of the map with the old style. So we have to clear the cache manually to fix this issue.

Thank you in advance!

Re: Clear cache if map updated

Hello.

You have several ways:
1. To check that the style has changed, download one tile (it is desirable that it contains the maximum amount of information that can be changed) and check the checksum. If the checksum has been changed, clear the file cache.

2. Make a request:

https://api.mapbox.com/styles/v1/{USER_ID}/{STYLE_ID}/?fresh=true&access_token={ACCESS_TOKEN}

You will receive JSON in response. Check "modified" field, and if this has changed, clear the file cache.

3. Use your own website or dropbox to keep a timestamp of when the style was last updated.
It can be a simple text file that contains the date and time. The main thing here is to remember to change the file when you changed the style.

3 (edited by sobkod23 2020-09-21 13:08:58)

Re: Clear cache if map updated

Ok, thanks!

And how I can clear the cache properly via the code after checking so there no old tiles left?

Re: Clear cache if map updated

OnlineMapsCache.ClearFileCache
https://infinity-code.com/doxygen/onlin … a11290cba2

5 (edited by sobkod23 2020-09-21 13:16:30)

Re: Clear cache if map updated

Hmm, I did it, but I see not only new tiles, but also old ones - some tiles are new, others are old

Post's attachments

Attachment icon 1.png 85.64 kb, 4 downloads since 2020-09-21 

Re: Clear cache if map updated

You mean that the map does not clear tiles that are already loaded in the current session, right?!
Reset the tile manager state:

map.tileManager.Reset();

7 (edited by sobkod23 2020-09-21 14:23:36)

Re: Clear cache if map updated

I don't know why, but it still doesn't work. Have you seen the image I attached above?

Although I cleared the cache, I still have old and new tiles loaded together, maybe something is wrong with getting data from the Mapbox?

Re: Clear cache if map updated

Perhaps Mapbox has cached these tiles and is returning old images.
To verify this, add the Online Maps Log component, and enable Show Request.
This will show all requests in the console.
Open the tile that has a problem in the browser to check if old or new image is displayed.

Re: Clear cache if map updated

If the browser displays an old image, then unfortunately I don't know a way to reset the Mapbox cache.
Here you need to wait until the cache is reset on the Mapbox side.

Re: Clear cache if map updated

I don't see Online Maps Log component

Re: Clear cache if map updated

The script is called OnlineMapsLog, but Unity uses a alias "Log" in the Add Component window.

Re: Clear cache if map updated

Thanks, I checked the tiles from the links in the logs and some of them turned out to be really old.