Closed Bug 742558 Opened 12 years ago Closed 10 years ago

put networking cache files in the Android cache dir

Categories

(Core :: Networking: Cache, defect)

x86
Android
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
blocking-fennec1.0 --- -

People

(Reporter: blassey, Unassigned)

References

Details

Android gives each app designated places to store cache files which don't count against install size and can be cleaned up by the OS if disk space is running low. We should use that directory for our caches.
blocking-fennec1.0: --- → ?
What are the rules of cleaning this place? Is the cache directory cleaned as a whole or could be removed just some files? Also is it guaranteed that the files are removed while the application is not running?
See http://developer.android.com/reference/android/content/ContextWrapper.html#getCacheDir%28%29

My guess is that we will have to do a lot of investigating to identify the exact behavior of Android w.r.t. the cache dir, as it is not documented very well.
blocking-fennec1.0: ? → -
I don't see any definitive/useful statement in the Android docs that will help us.

So...I tested on a Galaxy S running Android Froyo by copying 4MB files around on the /data partition. My findings:
 - cache directory cleaning is initiated when free space on /data falls below approx. 200 MB
 - there seems to be a time delay - perhaps 30 seconds - between the time the free space threshold is hit and the time that cleaning begins
 - the application cache directory is cleaned as a whole: all files and directories in the cache directory are deleted at one time
 - cache directory cleaning happens even if the owning application is running
I suspect the cache code would need tweaking to happily live in a world where all it's files disappear (or worse, are in the process of disappearing) while it runs.  IIRC we do a startup check that essential files are present, then assume they'll be there.  But I'm guessing that we can add some logic so that we re-create things if we detect that files are missing.  The trick is to know when it's safe to re-create the directory (it would suck to get into some sort of race where we're creating cache directory files while the OS is still purging the directory).  I wonder if there's any sort of API that makes that easier (ideally the OS would rename the temp dir and create a new one, then delete the old one in the background--that would give us some atomicity).
This was fixed by cache2 (bug 913806)
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
See Also: → 1388883
You need to log in before you can comment on or make changes to this bug.