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 patients requests 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?
Within Ezoics dashboard, if you are integrated either by Name Server, Cloudflare or CNAME you are able to manage your cache under the Speed header of the top nav bar, then navigate to the speed tab.
There are several options available just from what we first see in the cache section, lets keep to our Doctors 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 doctors office, this is the equivalent of the receptionist removing one of their stored copies of a form from the desk and shredding it, 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, 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 allowed for the rest of the sites 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.
Clear cache by multiple URLs
Clearing the cache by multiple URLs is very similar to clearing by a singular URL, it allows for multiple specific pages to be removed from the cache without clearing the cache completely. In terms of the doctors 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 page have been updated and you want to ensure the most current version of said pages is displayed to the user.
Clear all caching
Clearing the cache is exactly as it sounds, it removes everything stored within your websites 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 very fast way of removing stored content from the cache, you might also use this feature if the cache is presenting lots of old version of pages to users which have since been updated.
To go back to the doctors office analogy the office may have updated a lot of forms, so in order to avoid giving old copies out they empty the desk drawers and get rid of the old copies, leaving only the new files in the cabinet.
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, these help control how the caching behaves.
What is cache age?
Cache age is the amount of time 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 fill with documents.
Having too low of a cache age can result in inefficiencies whereby pages have to be relocated and re-cached which can result in longer page load times.
In the Doctors office analogy this would be the same thing as a form which is used everyday being stored in the desk and then and then removing it from the desk and shredding it 5 minutes later.
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.
Similarly caching pages which are not visited often for too long can have negative impact, this will result in unnecessarily storing pages (increasing the resources required for storage) and increasing the search time at the cache.
The equivalent of this in the doctor's office is the receptionist storing documents in the desk drawer for too long. This would make finding the right document in the desk take far longer and take up a lot more space in the drawers of the desk.