ElI5 why is the ‘cache’ this all powerful crasher of apps and causer of problems? Why does clearing it fix things?

637 views

ElI5 why is the ‘cache’ this all powerful crasher of apps and causer of problems? Why does clearing it fix things?

In: 101

22 Answers

Anonymous 0 Comments

A cache is a temporary storage space for data that gets frequently used. For example, when you visit a web page, the images on the page get downloaded, then put into cache. That way when you go back to that page again, it can pull the images from cache instead of downloading them again. Usually it makes pages load just a bit faster, and saves you a bit of data if you’re using mobile data.

But, if the cache gets too big, it can actually take longer to find something in cache than it would to just download it again. So if you clear the cache, it can sometimes help with performance issues.

Another thing that can happen is stale data in the cache. So, say something gets put into cache, but then the data gets changed. The app may not know that the data is stale, and will load the old version from cache instead of downloading the updated version. If you do that with code or scripts it can easily crash an app that expects the updated code. Clearing the cache forces the latest version to be downloaded.

Another thing that can sometimes happen is a corrupted cache entry, where something only got partially downloaded & stored in cache for one reason or another (battery died, internet went out, etc.) In this case, the app could get stuck trying to load a corrupted file from cache. And clearing cache will wipe out that corrupted file.

Now, most apps have measures in place to handle these situations automatically. Typically, the size of the cache is limited in order to prevent it from getting too big, and the oldest files in cache get deleted to make room for newer ones. Also, apps can check to see if a file is corrupt before attempting to load it from cache. And when the app downloads a new update, it can automatically clear the cache to handle the case of stale data.

But, not all apps have these features, and sometimes they don’t work as intended. For example, a 1GB cache limit might sound reasonable today, but if your device is 10 years old, that’s probably going to be too big.

Edit: word.

You are viewing 1 out of 22 answers, click here to view all answers.