chevron_right
chevron_right
A Simplified Guide to Caching
Informational/Resource

A Simplified Guide to Caching

Last Updated a few days ago
Article Navigation
Introduction
How caching works for beginners
Tips and Best Practices

Introduction

Welcome to our simplified guide to caching! Caching can initially seem complex, but it’s a powerful tool for improving the speed and efficiency of your website. This article aims to demystify caching by explaining its basic concepts and offering step-by-step instructions on how to manage cache effectively using Ezoic's platform. By the end of this guide, you’ll understand how caching works, how to clear cache by URL or multiple URLs, and how to adjust various caching settings to optimize your site’s performance. Let’s dive in and make caching work for you!

How caching works for beginners

Caching can be quite a complex thing to get your head around when it comes to websites, but did you know that you likely use caching in your daily life already?

Caching is simply the process of storing commonly used data so that it can be accessed more quickly in the future, without the need to locate it in a larger store of data every time it is required. This is done by dedicating memory to storing such commonly needed information so that it is close at hand, In terms of your website this means that your most popular pages and articles get stored in a quickly accessible way, so that when a visitor requests to view one of your pages it can be served more quickly than going to the central store of data for your website (your host server).

To better understand this here is a more relatable example…

Imagine a reception at a doctor's office.



When a patient comes to receptionist's desk with a request for a commonly needed form, the receptionist with normally have to get up, go to the filing cabinet, search for the specific file, then walk back from the filing cabinet and hand it to the patient. Quite a lengthy process…

 



Instead however if the receptionist used the drawers in the desk they could save both the patient and themself a lot of time, as well as the energy of having to go over to the filing cabinet and find the file they need. In this case a patient comes to the receptionist requesting the same commonly needed form, the receptionist goes to the filing cabinet, searches for the file, brings it back to the desk and hands it to the patient. The receptionist then stores a copy of the document within their desk for easy access.

The next time a patient comes to request a form the receptionist then checks the desk drawer first to see if they already have the form in their drawer which they can hand a copy of to the patient. If they do then they can hand the form straight to the patient without the need for walking all the way back to the filing cabinet, if they don't then they simply go to the filing cabinet again but bring back a copy of the form the newly requested form and store that in the desk also.

In this example the patient's request represent the user's page request, the desk drawer represents the cache and the filling cabinet represents the store of your websites data at the host server (often called the origin).

Caching is essentially a trade off in resources, trading a small amount of memory or storage for speed - this ensures that when a user requests a webpage it can be accessed quickly.

How can you manage the cache?



If JavaScript integrated with Ezoic, you can use a third-party CDN to cache your site. If you are integrated by either name server, Cloudflare or CNAME, you are able to utilize and manage Ezoic's cache via https://pubdash.ezoic.com/settings/caching (found via Settings > Caching). In this case, you will see a screen that looks something like this:

 

As you can see, there are several options available to you for managing the Ezoic cache. To better explain what each one does, let's keep to our Doctor's office example for each…

Clear cache by URL



Clearing cache by URL allows for a specific page to be removed from the cache. In terms of the doctor's office, this is the equivalent of the receptionist removing one of their stored copies of a form from the desk and shredding it, then when that form is requested again the receptionist will have to go back to the filing cabinet and search for the form again. The receptionist may do this if they know the stored form is out of date and has been replaced with a new one found in the filing, therefore they do not want to accidentally hand the old form out to patients at the desk so remove it and shred it. 


Clearing the cache by URL is useful as it allows for the rest of the site's cached pages to remain cached, thus maintaining the speed benefit of those pages whilst allowing the removal of the out of date page from the cache. So you would want to use this option if you've made changes to a single URL on your site only, and want your users to be able to see the updated version of this page whilst serving all other URLs from the cache.

Clear cache by multiple URLs


Clearing the cache by multiple URLs is very similar to clearing by a singular URL, however it allows for multiple specific pages to be removed from the cache without clearing the cache completely. In terms of the doctor's office this is the equivalent of the receptionist getting rid of multiple specific forms from the desk drawer but not emptying it completely.

This has the same benefits of clearing the cache by a single URL only you are instead clearing the cache for multiple pages instead of just one. This is useful if multiple pages (but not all) have been updated and you want to ensure the most current versions of said pages are displayed to the user.

Clear all caching



Clearing the cache is exactly as it sounds, it removes everything stored within your website's Ezoic cache.

If you wanted to think of this in terms of the Doctor's office analogy, this is the equivalent of of picking up the desk and shaking it until all of the documents stored in its drawers are no longer stored there, then shredding each of them so that a new copy of each must be retrieved from the cabinet if a patient request it.

This is useful as it is a very fast way of removing stored content from the cache. You might use this feature if the cache is presenting lots of old versions of pages to users which have since been updated.

There is the disadvantage however that after clearing the cache entirely initial page load speed will be lower and every page will need to be re-ccached.

Try not to clear the cache unless several pages require a new version to be shown quickly.


Other Cache settings



Further down in the caching section there are more in-depth caching settings for managing the cache.



What is cache 'age'?



Cache age is the amount of time during which a page is stored within the cache.



To tie this into the doctor's office analogy this is the equivalent of each document stored in the drawer having a time to dispose of the copy by. The documents are assigned this time value so that the desk does not inadvertently fill up with old versions of documents that are frequently updated. Having too high a cache age could similarly result in old versions of pages that are frequently updated being served to the user.


On the other hand, having too low of a cache age can result in longer page load times as the cache constantly needs to be rebuilt, even when this is unnecessary because the page hasn't been updated.



In the Doctor's office analogy this would be the same thing as all the forms in the Receptionist's desk being shredded every 5 minutes (for example), despite the fact that most of the forms are only updated every few months.

This is clearly silly and inefficient as every 5 minutes the receptionist will have to go back to the filing cabinet to get a new copy to give to the requesting patient and store in the desk.

It's important then for the Receptionist to strike the right balance between not storing old versions of documents in their desk and ensuring they're not constantly having to fetch documents from the filing cabinet. This balance will be different for every Receptionist depending upon how often their forms are updated. Similarly, site owners will need to find the right balance when setting the cache age for their site.

Tips and Best Practices

  • Try not to clear the cache too often.
  • When clearing the cache, clear by URL unless implementing site-wide changes.
  • Utilize the Ezoic WordPress Plugin for CDN Management so that pages automatically refresh after changes.
× Enlarged Image

Loading ...