How does caching work?
Caching works by putting website elements into little pockets along the system, so they’re faster to access. These pockets can be on your device (phone, tablet, or computer), in your local network, in your web browser, or in the website server.
Analogy: Say you’re going for a walk on a chilly day. You may grab a handful of tissues to put into your pocket for the walk. This is a cache of tissues. Now you don’t have to go all the way back to the house every time you have a sniffle.
The first time you visit a website, your device grabs all the information it needs for you to see the pages properly. At that time, the site leaves traces of itself in your device so that the next time you call it up, you don’t have to retrieve everything again.
Systems that implement various types of caching are helpful for big sites that get surges in traffic, for example on Black Friday. Because various bits of data are scattered in caches in different points along the path, the load doesn’t bottleneck in one place.
Say a website has 1,000 products for sale. The site may be coded so that there is a database on the server and a template in a cache between the server and the command that allows you to see the site. When you ask to see that gorgeous sweater, the server retrieves the data about the sweater, feeds it through the template, then gives you the output in the form of a page. You may go on to look at a pair of pants next. The template has now been cached in your browser so all you need to retrieve is the database information. Et la voilà: the page loads faster.
In this system, there is a database which includes information for each product. That database is fed into a page template and delivered to your device. When you want to look at another page, you already have the template information, so the only thing the server needs to send you is the database information.
Clear your cache
Once in a while, it’s good to clear out your cache, for a couple of reasons. A cache can become so full of older items that there is no room for new files. You may not be using the same sites you did a month ago, so clearing out that data frees up that room.
Secondly, you want to make sure you have the correct data when you look at a site. Say you looked at a website Monday. Your browser or device will make a cache for that site. Tuesday the site is updated. You go back Wednesday to look at the site again, and depending on how the site is configured, you may see the update or you may not. So not only is it safe to delete your cached files – it’s also a good idea.
When you clear your cache, all the cached data stored in your device or browser is deleted, so when you go back to that site, it’ll have to be loaded again and might take a second or two longer. You may also notice that accounts that are normally open (i.e., LinkedIn or Facebook) have been logged out. You will have to log back into those.
I use SiteGround’s caching tools on my websites, which are part of SiteGround’s Optimizer plugin. There are plenty of other plugins you can use but if you host with SiteGround, I recommend using theirs. I like that the system is provided by the same company that hosts my sites, so the integration is seamless.
SiteGround uses three types of caching: NGINX Direct Delivery, Dynamic Caching and Memcached. For a complete description of how these tools work, see their explanation here.