Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Add API to clear ambient cache #4376

Closed
1ec5 opened this issue Mar 18, 2016 · 14 comments · Fixed by #14702
Closed

Add API to clear ambient cache #4376

1ec5 opened this issue Mar 18, 2016 · 14 comments · Fixed by #14702
Assignees
Labels
Android Mapbox Maps SDK for Android iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS offline Qt Mapbox Maps SDK for Qt, aka Qt Location Mapbox GL

Comments

@1ec5
Copy link
Contributor

1ec5 commented Mar 18, 2016

As of #4376, all cached resources are located in a file in Application Support instead of Caches, so any disk space taken up by ambient caching cannot be automatically reclaimed by iOS when disk space runs low. These resources are only removed when the application is deleted. This would become more of a problem if the application is permitted to raise the ambient cache size (#3437).

Perhaps MGLOfflineStorage should have a method that clears the ambient cache contents in the unified cache file, leaving any downloaded offline content intact. The application could provide UI for reclaiming the space taken up by ambient caching.

/cc @jfirebaugh

@1ec5 1ec5 added iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS offline labels Mar 18, 2016
@zugaldia zugaldia added the Android Mapbox Maps SDK for Android label Mar 18, 2016
@zugaldia
Copy link
Member

Adding the android tag as the current situation affects Android similarly.

@tsemerad
Copy link

tsemerad commented Sep 6, 2016

Is there still no way to clear the ambient cache, other than reinstalling the app? I'm finding that when I update a tileset, my iOS client is still holding onto the previous tiles. Previously-cached tiles still show the old data, but fetching new tiles show the new data.

@1ec5
Copy link
Contributor Author

1ec5 commented Sep 6, 2016

Is this tile set hosted by Mapbox or by you? If you’re hosting your own tile set, you can set a caching header in the HTTP response to force regular refreshes: #4446 (comment).

@tsemerad
Copy link

tsemerad commented Sep 6, 2016

It's hosted on Mapbox. Do you know what Cache-Control: max-age header Mapbox serves the tiles with?

Hosting the tiles myself wouldn't be ideal, but I can do so if necessary. But doesn't the new offline caching functionality (where you set a region) require that the tiles be hosted by Mapbox? Maybe I'm misremembering.

@zugaldia
Copy link
Member

zugaldia commented Sep 8, 2016

Just noting that, on Android, this is something that can easily be implemented by the developer today. For reference, we currently have a private method deleteAmbientDatabase that deletes the database that we used to use before offline landed. (This method name needs to be clarified once this new API is introduced.)

To delete the current database, the developer would use similar code. The path could be obtained from OfflineManager.getDatabasePath() and the filename from OfflineManager.DATABASE_NAME.

In any case, I like the idea of adding a specific API in the SDK.

@1ec5
Copy link
Contributor Author

1ec5 commented Sep 8, 2016

Similarly, on iOS and macOS, it’s possible to delete the database (which contains all cached content, including downloaded offline packs) by pointing NSFileManager to this path. But the location of that file may change in a future release without notice, it’s probably only safe to touch this file before you use MGLMapView or MGLOfflineStorage in any way, and we don’t make any promises about how well this workaround would work even today. I’d expect the same caveats to apply to the Android SDK. So I’m pretty sure deleting the database isn’t an option for the use case described in #4376 (comment).

@RomainQuidet
Copy link
Contributor

Hi,
Any news about when this feature will be added ? which milestone ?
Thanks.

@Superfuture
Copy link

Hi, any ETA on when this will be fixed? Thanks!

@haydenkaizeta
Copy link

Android ETA?

@rinigus
Copy link
Contributor

rinigus commented Feb 24, 2018

If such API will be developed, would be great to get it for Qt as well.

@1ec5 1ec5 added the Qt Mapbox Maps SDK for Qt, aka Qt Location Mapbox GL label Mar 6, 2018
@jeffypooo
Copy link

+1 We'd love to have this feature.

@zugaldia
Copy link
Member

/cc: @tmpsantos for prioritization.

@kkaefer
Copy link
Member

kkaefer commented Apr 26, 2019

PR is in #14365

@brunoabinader
Copy link
Member

Worth noticing that #14365 resets the entire database, including ambient cache and offline regions. As per discussions with @kkaefer, we should be able to clear ambient cache independently from offline regions via SQL queries.

@tmpsantos tmpsantos self-assigned this May 6, 2019
tmpsantos added a commit that referenced this issue May 17, 2019
Add new APIs for invalidating tiles, effectively forcing Mapbox
GL Native to check with the servers if the tiles are valid before
using them. This is more efficient then deleting tiles, because
in case of valid tiles, they won't get downloaded.

Fixes #4376.
tmpsantos added a commit that referenced this issue May 20, 2019
Add new APIs for invalidating tiles, effectively forcing Mapbox
GL Native to check with the servers if the tiles are valid before
using them. This is more efficient then deleting tiles, because
in case of valid tiles, they won't get downloaded.

Fixes #4376.
tmpsantos added a commit that referenced this issue May 20, 2019
Add new APIs for invalidating tiles, effectively forcing Mapbox
GL Native to check with the servers if the tiles are valid before
using them. This is more efficient then deleting tiles, because
in case of valid tiles, they won't get downloaded.

Fixes #4376.
@friedbunny friedbunny added this to the release-oolong milestone May 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS offline Qt Mapbox Maps SDK for Qt, aka Qt Location Mapbox GL
Projects
None yet
Development

Successfully merging a pull request may close this issue.