Web: Cache

From SupportWiki

Jump to: navigation, search

Contents

What is a cache, anyway? Can I spend it?

A cache is a copy of some or all of the files from an internet site that your browser downloads when you visit that site. If you return there within a certain period of time, the browser displays the copies instead of going to the site again to retrieve the files, which speeds up your browsing and saves bandwidth for both you and the host in question.

Generally, a server will tell the browser how long a particular file should stay in the browser's cache for. Some files, such as the main search form for Google, are unlikely to change over the course of the day. Others, such as the evil overlord list, are unlikely to ever change. And still others, such as most pages on LiveJournal, are expected to change virtually every time you view them. In each case, the server will instruct the browser to only hold onto the file for the appropriate amount of time, so that the user never (or rarely) sees an out-of-date version of the file. Further, when the browser does ask for a new copy, it can ask only for information about the file (such as the time it was last updated) rather than the file itself, and compare that time to the last time it retrieved it, to avoid having to download the file again if it hasn't changed.

This all sounds great. So what's the problem?

The problem is that certain "browsers" tend to ignore the information that the server sends about how long a page should stay in cache for, and cache it for as long as they feel like caching it. Further, most browsers contain user-settable options that can override the server's settings for how long something should stay in cache. In either case, a user can be left seeing an old version of the page instead of the one that's currently on the server.

So what can be done?

There is a FAQ which addresses specifically this issue. The FAQ should be referenced in any cache-related answer; it covers force-reloading and explains how to clear the cache for common browsers. Clearing the cache will allow the user to see the most recent version of the page, and hopefully get around whatever problem they're currently experiencing.

Note that the cache-clearing howto tutorials should no longer be linked to in support answers, as they haven't been kept up to date and don't cover newer browsers or current versions. They are kept for historical reasons only.

How can I tell if something is a cache problem?

Here are some common signs of cache problems:

  • The user reports that their friends page or journal isn't taking updates when they know updates have occurred, particularly if you can see updates that they don't seem to be able to.
  • The user reports that the "Update Journal" link on the LiveJournal home page takes them straight to the results page (the one containing links to memorify or view the updated entry).
  • The user sees information that should only be visible while logged in even after logging out, or cannot see information that should be visible after logging in.
  • The user receives an error about the page being too old when attempting to log in.
  • The user has received e-mail notifications of comments on a journal entry, but can't see them through the web interface.
  • The user reports that something is behaving in a way which is not consistent with recent patches. For instance, the user may not be able to see newly-added elements on the comment interface.


Please be aware that this isn't an exhaustive list. Caching can cause many different kinds of errors, and diagnosing some of them may require some detective work. In fact, if you encounter some kind of strange problem, one of the first questions you should ask yourself is: how could caching cause this? You won't always find a solution that way, but cache problems will be a consistent nemesis for you as you continue your work in Web, and it's best to begin learning to hate them early.

Personal tools