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

613 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

The cache is where all your bad thoughts go.

Clearing it gets rid of those thoughts and makes the world look like a bright and beautiful place again.

Anonymous 0 Comments

In the words of Homer Simpson: “To cache! The cause of and solution to all of life’s problems!”

Anonymous 0 Comments

Imagine you land the excellent job of being clerk at a library. You’re in luck, it is a huge library! People come to your desk and queue up to ask for a particular book, so you go and get it for them. Some books take longer to fetch than others (big library has downsides!).

You notice that the queue can get long and you’re constantly busy fetching books, often the same book that happens to be popular! To save yourself time and speed things up for your clients you put a box on your desk, you give it the funky name of ‘cache’ but it’s just a box really, to put things in.

In that box you put copies of the currently popular books, so when people come and ask for it you hand it to them real quick. It works great!

Now it can cause problems, what if lots of books are popular and you keep piling more books in the box. Eventually it’ll be extremely heavy and your desk is struggling to hold it. Better limit the size of your box.

Or a new revision of a popular book came out but your box is full out of outdated copies! Oh no now you give your clients an old copy and they want the new. Better empty that box and go and fetch latest.

Replace the library with your app/site and the books are the content you see as a user of that app. A cache speeds up delivery and reuse.

Anonymous 0 Comments

Cache is all the temporary files an app creates. For browsers that is saving copies of the websites you’re visiting so it doesn’t have to keep requesting the same pages/images/etc over and over again (web pages actually tell the browser of they should be saved like this and for how long).

For mobile apps it’s really anything they might need to store that doesn’t all fit in RAM.

If something bad gets written to the cache (say a webpage is down and the broken requests get cached, or an app crashes in a way that writes bad data in the cache) then this could cause problems for the app. As cache is only meant to be temporary if you clear it the app will happily reload whatever it needs, potentially fixing a previous problem.

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.

Anonymous 0 Comments

Say you’re trying to call a friend. You recall their number from memory, dial it in, and find that it doesn’t work. You try again, and it still doesn’t work. Maybe it’s a problem with their phone, the service, or some other factors, but all you know is that you’re dialing the correct number that you remember, the same way you’ve done hundreds of times before, and it’s not connecting.

At some point you decide to find their contact info. This takes some time since you don’t use your contacts app that often and aren’t even sure where it is on your home screen, and discover that they in fact changed their number, meaning you have to call them using the new one.

In this example your memory is the cache. It’s a fast way of retrieving information for a given task, at the risk of potentially being out of date or otherwise no longer correct. Web browsers and other applications follow a similar process – Loading data from the internet every time for something that’s not likely to change very often is inefficient, so these programs ‘remember’ what the data is and simply load it from RAM or disk when needed provided it hasn’t been too long since the last update. Usually this is configured in such a way that your program should always have the latest data when it needs it, however if the app misconfigured its cache policy it can lead to situations similar to the example above.

Clearing the cache effectively forces your program to get the up-to-date data before proceeding, as slow as it may be, fixing your version of the app.

Anonymous 0 Comments

Imagine you discover a restaurant that you really like and you keep ordering from them every day. Each time you order, you have to look up their phone number to call them

After you call them enough times, you don’t need to look up their phone number anymore because you’ve memorized it.

This makes it easier to order because you can skip the step of looking up the phone number.

One day, the restaurant changes their phone number. Now when you call the number you’ve memorized, you get an automated message saying the number is disconnected.

You can’t order anymore until you look up the new phone number.

A cache is like your brain’s memory – it is simply a place for your computer to remember stuff quickly instead of looking it up. Usually it just caches stuff that doesn’t change a lot, but if that stuff DOES change, then your computer doesn’t realize it until it checks (because the whole point is to not be slowed down by checking).

So if your computer’s cache has old “stale” information in it. It can sometimes lead to unexpected results.

Anonymous 0 Comments

Imagine you need to take the train and the train schedule is 500 pages. It takes a long time to find the schedule for your stop at 9 AM (when you typically go to work), so once you figure it out you write it down in your notepad and just check the notepad. Unbeknownst to you the train schedule changes and it now arrives at your stop 15 minutes earlier. Until you scratch out that note in your notepad or update it by looking up the updated time, you’re going to miss the train. (Likewise your friend could decide to play a prank on you and rewrite or erase the time in your notepad…)

Anonymous 0 Comments

A browser cache prevents you from downloading something twice unnecessarily. If every page of a website has some common images, CSS, JavaScript or makes some repeated requests for the same data, it would be a waste to redownload it if we thought it was unlikely to change. Having a cache saves bandwidth and makes pages load faster.

However, some data does need to be downloaded regularly and shouldn’t be cached, at least not for long.

Every time the web browser receives something, the server also tells it how long it should cache it for. This way the browser doesn’t need to be smart, the programmers of the server can decide what the right amount of time for the cache is.

However, sometimes (often) they get it wrong and they set a cache time that is too long. Perhaps it should never cache but some junior programmer somewhere forgot to change the default. Unfortunately, even if they notice the problem fairly quickly, your cache trusts what it sees and decides not to redownload this file, which means it never sees the fixed cache time.

This is called cache poisoning.

If this is a JavaScript file, it might mean your browser keeps running an old version of code, which no longer works properly. If it’s a data response, it could mean you keep seeing our of date data. All kinds of things can go wrong at this point.

Clearing the cache is a simple and reliable solution.

Anonymous 0 Comments

Clearing the cache is like hitting the reset button for your forgetful computer. It’s memory needs a good slap sometimes!