Drupal keeps all text-based content in a set of database tables. These tables contain the content, metatags, forms, menus, headers, footers, and more. Drupal's job is to fetch all these pieces from the database, insert those pieces into a page template, add any additional code (such as CSS, Javascript, and images), and finally convert it into a valid HTML 5 page.

To make a single HTML page, Drupal typically makes between 15 and 75 database queries, fetches up to four dozen CSS and javascript files, and plugs these components into one (or more) types of templates and sub-templates. It takes a significant number of processing steps to create the finished HTML page that you see in the browser.

A cache (pronounced like "cash") is a large chunk of memory that keeps a copy of each finished HTML page. Instead of waiting for Drupal to build you a fresh version of the HTML page, you will often see the (pre-built) cached version, instead.  Cached pages display much, much faster. And because they are pre-built versions of your HTML page, there are no intermediate processing steps. The finished HTML page is ready to display instantly. Cached pages are extremely fast.

Your Best Friend

Caches give you the best of both worlds. You can have extremely complex HTML code. And you can display that HTML very quickly. Best of all, this all happens in the background. You do not need to add your pages to these caches. By default, all content is cached. Because they are so useful, nearly every web component has at least one type of cache. (Your browser has a cache. The web server has a cache. The database has a cache. The web server's operating system has a cache. And Drupal has an entire caching system.  There are many caches to serve you!)

Your Worst Nightmare

If you are editing a page, caches can be your worst nightmare. Imagine spending two hours crafting a lengthy page, clicking Save, and emailing the link to your co-workers to review. Your co-workers click the link and see the old version of the page -- but they don't see any of your work. Your co-workers are seeing the old, cached version of your page -- not your new version.

Most modern caches have an expiration time -- they will not keep any content that is more than a few hours old. (Most of our caches expire in one to six hours.) So a customer visiting your site once a day (even three times a day) will see the freshest content. But if you are editing and reviewing content, you want to see your changes now -- not in a few hours. You need to bypass the caches to get the latest version of your page.

 

Bypassing the Caches

Method #1: Charlie's Magic Query String

The easiest and most effective way to bypass a cache is to add a random argument to the URL of your page.

Here is the URL to a sample page on Sonosite.com. (By default, it is cached.)

 

To fetch the newest, freshest version of the page (and override the caches), add ?beer=good to the end of the URL, and load that page:

Because none of the caches have ever seen a page at that address, the caches are skipped. You get a fresh version of that page, directly from the web server. This method will bypass all types of caches -- but it does not refresh or rebuild the cache. (If you went back to the first page, you'd still see the cached version.)  It also works on non-Drupal web sites.

The next time you need a fresh copy of the page, though, you'll need to use words other than beer and good. (When you loaded that fresh version of the ?beer=good page, it was added to the cache.) You can use any words you like, such as ?sonosite=cool  or ?foo=bar or ?x=yz. (Just remember to include the ? and = characters.)

 

Method #2: Clear Drupal's Cache

From the Drupal admin menu, hover over the Sonosite logo and select Flush all caches:

 

This can take 20-60 seconds to process. It erases all of the content from Drupal's caching system. (It does not affect any other caches.)

Because this removes all of the pages from Drupal's caches, our customers will experience a slow-loading web site. (It will continue to be slow until the caches are rebuilt.) Because of this, method #1 is preferred, because it does not affect the cache.

 

Method #3: Shift + Reload

This is one of the oldest methods of clearing a cache. While pressing the [SHIFT] key, click your browser's Reload icon. 

(On some browsers, the Reload icon is on the left-had side of the URL.)

This method empties only your web browser's cache. It does not affect the Drupal cache, or any other cache system. (And it is not guaranteed to work with all browsers.)

After you have emptied your caches, you should see the latest version of your edited page.