📜 ⬆️ ⬇️

Clearing the cache in iOS 5



Each iOS application has a working folder for storing files. All items from there, except for the contents of Caches and tmp , are synchronized with the backup while connecting to iTunes.

Before the release of iOS 5, the system never deleted the contents of Caches and tmp , they were the only safe place to store data that should always be available and at the same time that can be re-downloaded in case of loss. Thus, this data did not take up space in backups and did not slow down synchronization.

In iOS 5, after iCloud backups have appeared, Apple has begun a battle with apps that store too much data in any synchronized folder, such as Documents . Many developers have already received letters from Apple like this:
')
During the last test, it was discovered that [your application] stores a significant amount of data in the Documents folder.

Since iCloud backups are performed daily via Wi-Fi for each iOS device, it is important to ensure maximum user convenience and minimize the amount of data stored by your application.

In addition to the purchased music, applications, books, photos and device settings, all the contents of the working folder of your application, including the Documents folder, are synchronized with iCloud.

The program itself, as well as the Caches and temp folders are not synchronized with iCloud. Your application must store data in specified locations, in accordance with the rules for using iCloud storage .

Please review the specified documentation, make the necessary changes and update the version of the program in the App Store.

The documentation explains everything very clearly:

  1. Only documents and other data created by the user or that cannot be recreated by your application should be stored in the <Application_Home>/Documents folder and will be automatically synchronized with iCloud.
  2. Data that can be re-downloaded or recreated by the application should be stored in the <Application_Home>/Library/Caches . For example, these are database cache files or downloadable content, such as what is used by applications for reading magazines, newspapers and mapping applications.

It sounds simple: move everything you can re-download in Caches .

Instapaper has long been keeping downloaded articles in the Caches folder, because I didn’t want to slow down users' syncing with iTunes and increase backups unnecessarily, and a complete database update didn’t happen so often to be a problem for most people. New rules force me to use Caches : I no longer have a choice.

But in iOS 5 there is another important change: Caches and tmp - the only two places that are not included in the backup - are cleaned when the device runs out of memory.

Many developers have reported this problem with Instapaper even before iOS 5 became available to the general public, so I am horrified to imagine how many complaints there will be when mass sales of devices with iOS 5 begin.

Now there is no place left where to store files that are not needed to be backed up (or even forbidden to be backed up, according to the new rules), but which cannot be deleted at an arbitrary time. This is a problem for many applications, these are the ones that immediately come to mind:

  1. Instapaper and other programs that save web articles for offline reading.
  2. Applications for reading electronic books (including iBooks, if the rules apply to it)
  3. Podcast clients (except for those podcasts that sync with iTunes)
  4. Offline Wikipedia
  5. Offline mapping software

The keyword is offline . You can say that there is no big problem here, because you can download everything again from the Internet at any time. But this is not the case.

A typical scenario: Instapaper user fills his iPad with content for a long journey. It synchronizes a pack of movies and podcasts, downloads several magazines and buys a couple of new games, so that as a result, there is almost no free space on the device. Right before boarding the plane, she remembers that you need to download the latest issue of The Economist magazine (I have a high opinion of my users). Because of this, the amount of free space falls below the critical point and a trigger is triggered, which runs the cleaning program in the background. Unnoticed by the user, everything that she saved in Instapaper is erased. Later during the flight, where there is no access to the Internet, she launches Instapaper and finds the program pristine.

(Last week, almost exactly such a case occurred with one of my users).

Because of this, everyone suffers:


Everything gets worse if you think how often access to the Internet is difficult or impossible:


Even if you always have a fast and reliable connection to the Internet, the sudden removal of data in the application in any case presents a problem.

When a user saves an article to Instapaper, downloads a book to iBooks or a podcast to Instacast, he expects the content to be available the next time the program is launched. Even if it is technically possible to re-download, the person views this content as his files - he personally put them here and he decides when and whether to delete them.

When the cleaning program erases everything, it looks like the application has deleted its data. And the user doesn’t even know that this is a feature of iOS 5 - he logically blames application developers. Although it is not our fault, it will definitely become our problem.

Obviously, there must be a place to store files, like Caches before iOS 5: without backup on iTunes or iCloud, without synchronization. There, the files will be intact until the program itself is removed from the device.

The author of the text is Marco Arment, the author of the program Instapaper.

Source: https://habr.com/ru/post/130393/


All Articles