Offline Maps and iOS 5's Cache Cleaning Policy

By Justin Miller on Oct 17 2011 . Posted in MapBox.

One of the flagship features of our MapBox for iPad app is the use of maps while in an offline environment. When we created the MBTiles format over a year ago, we solved a common problem of storing potentially millions of map tile images efficiently and conveniently for offline use.

Our app stores tilesets that you sync (and soon, that you download from in the app itself) in the app's Documents folder, which is Apple's recommended place for this sort of data. According to Apple's documentation (free developer registration required):

Only documents and other data that is user-generated, or that cannot otherwise be recreated by your application, should be stored in the <Application_Home>/Documents directory ...

It goes on to mention the Caches folder as well:

Data that can be downloaded again or regenerated should be stored in the <Application_Home>/Library/Caches directory. Examples of files you should put in the Caches directory include database cache files and downloadable content, such as that used by magazine, newspaper, and map applications.

While the documentation mentions map applications, since our app is a tool for creating your own highly custom maps, as opposed to purchasing maps from a centralized source, we've always felt that Documents was the right place for this data. This is especially true when you consider that the main way that people get this data into and out of the application is through syncing with iTunes, which only exposes the Documents folder.

Recently, Marco Arment of Instapaper fame blogged about a change in Apple's 'cleaning' policy:

In iOS 5, since iCloud backups are now possible, Apple has started cracking down on apps that store too much in any backed-up directory, such as Documents.

...

But in iOS 5, there’s an important change: Caches and tmp — the only two directories that aren’t backed up — are “cleaned” out when the device is low on space.

The end result here is bad news either way for users of iCloud and apps like ours. Either they take up much, if not all, of their cloud storage space storing map tilesets, or they have their data deleted at random times without advance notice.

Marco summarizes the issue well at the end of his blog post:

There needs to be a file storage location that behaves the way Caches did before iOS 5: it’s not backed up to iTunes or iCloud, it’s not synced, but it’s also never deleted unless the app is deleted.

Here's another vote from us for that.

0 tweets link to this blog post. Start a conversation with @developmentseed on Twitter.

Search

No results found.
About
Projects
Team
Blog