Understanding Caching and How to Use

Current Progress
Current Progress
Current Progress
Current Progress

Introduction

Caching - “to store away for future use” which is a pretty good description of the term. In the context of the internet, caching is used in many different places – in your web browser, domain name servers, content delivery networks, web host servers amongst others. The general principle of caching is to store a copy of data locally rather than request it from its actual original source (which could be held on a server on the opposite side of the world) each time it is accessed. This cuts down internet traffic and speeds up the user experience. There are mechanisms also to allow caching systems know when to go and get a fresh copy (refresh) of the data held at the source.

The annoying thing that you’ll witness in conversations in social media threads and other places is that people will say things like “oh, that’s probably a caching issue …” without qualifying what caching they are specifically talking about.

The typical problems that arise are that you make a change to a web page but you don’t see it when you browse that page when logged out of your web editor. Or other users still see the previous version of the page. This happens because the caching systems haven’t all updated – it takes time for changes to propagate across the internet.

Caching is all over the web!

A very useful resource is

GeoPeeker - See how a site appears to the rest of the world

The easiest caching to understand is where web pages you visit are stored on your computer so when you look at them again they don't have to be re-downloaded from the internet. This is called browser caching. Now, that is a very simplistic view but it really does tell you the essence of what you need to understand.

Caching is used to improve the user experience by making web pages load faster in your browser. Web pages may reside on the opposite side of the globe from where you are viewing them and there will be a lot of internet hops across internet infrastructure that will slow down page delivery from where it is to hosted to where your browser displays it. Plus traffic volumes will add to slowing down delivery. Caching is a way of providing the nearest and quickest mechanism to loading the web page into your browser.

How Caching Works with Your Site

There are clever mechanisms to tell the browser when a page has changed in order to fetch a new copy.

Caching gets more complicated in the internet world because caching happens on the web host and on content delivery network servers (see the lesson on CDN). There are several points along the path from your PC (or tablet or smartphone) to the webserver where the web page resides where caching takes place. Domain names get stored in name server caches.

WordPress stores content in a database and this content is assembled into a web page and sent to your browser on the fly (dynamically). This task places a processing burden on the server and so the server will keep an assembled copy handy (in a cache) for when someone else requests the same page. This saves the database from having to be queried again in order to retrieve the page content items. Clever algorithms determine which pages get cached and for how long. Cache memory operates between 10 to 100 times faster than RAM, uses more power and is a lot more expensive. So clearly a web server can deliver a page more quickly from its cache than by having to build it by retrieving content from the database.

Caching makes everything work faster. You can run into problems sometimes where you find you are looking at a web page and see a different view to someone else. You can clear your browser cache ctrl-shift-delete and also your web host cache by logging in to your hosting account where you should have access for tools for doing this. It may also be possible to clear and disable/enable your CDN which can be helpful when troubleshooting.

DNS name servers cache addresses in a similar fashion - ones that don't get called for often will drop off the cache of a given server.

That's it!

For a more in depth look at caching, have a look at this article.

View Cache Data With Chrome DevTools

  • 👍 TIP - The key take away to remember is that if you don’t see what you expect to see on a web page, chances are that somewhere between your computer and the originating website, caching (at one or more points previously described) may be holding out of date content that you are seeing.

Recommended Resources

Join Our Facebook Group

Our community is filled with awesome, like-minded individuals who love to share ideas and resources!

Take the Lesson Quiz

Current Progress
Current Progress
Current Progress
Current Progress
{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
Pen
>