One way to improve website performance is to cache data. To help you understand how you can do this, we use this occasion to talk about various aspects of caching.
Good morning, Richard.
Thank you for joining us again. Can you tell me what caching is, please?
Caching is the mechanism of pre-building and storing the files of a particular web page on the hard disk or in memory. So, rather than having to access the original server repeatedly in order to view a particular web page, you will access the files stored in a cache. This will save the original server the burden of additional work and potential slow downs.
Why do that?
Caching reduces the load on web servers, leading to less CPU and less disk usage. Depending on how you implement your caching solution, files can be stored in the computer’s memory, which is the cheapest mechanism for serving a page.
So, you say that caching allows people to access web pages by a much shorter or efficient route. Is that correct?
That’s right. If you go for a managed caching solution, for example, a particular request for accessing a web page will typically be served by a caching layer, though it may also reach the original server. On the other side, if you go for a WordPress plug-in solution, the request may still reach the server; however, the WordPress plug-in will facilitate the access to a particular web page much faster and more efficient than a managed caching solution.
So, there are different solutions and different ways of doing caching. Is that right?
Yes. There are a couple of options, but it really depends on your traffic profile. Is your WordPress website really big? Does it have, for instance, 60,000 posts? Does it experience high levels of traffic from only a few pages? The broadcast of a newsletter to a large audience might drive traffic to only ten pages?
Coming down to the shape of your traffic, it really depends on the type of solution you choose. If you have a very broad website with lots of posts, but you only get a few requests to each page, you need to make sure that the solution you use is caching for the right amount of time. So, there’s no point in caching 60,000 pages for 10 minutes if the average request per page is once every 20 minutes. This is going to increase the load on the web server. So, it is important to choose the right caching solution for your traffic profile.
You talked about a managed service and also a WordPress plug-in. Are there any other caching solutions?
Yes, there are. I would say that your two best alternative bets of caching solutions are: 1) to put your own caching layer in, so your solution will be easier to set up and configure to your needs; 2) the other option kind of sits in the middle of using your own caching layer and using a WordPress plug-in. Although WordPress plug-ins are really, really good, they need to be configured. You need to write codes specifically for plug-ins to work properly, otherwise they’re just going to transfer the load onto the disk, slowing down the computer. So, WordPress plug-ins can have a negative effect sometimes.
So, is there anything you would recommend that we should investigate further?
Before you choose a caching solution, you need to analyse your traffic profile with specific tools, such as Google Analytics. By actually looking at the shape of your traffic (When does it spike? How does it spike? What is the number of pages accessed?), you can find out exactly what’s going on, analyse the behaviour of your website, and other things, such as when and how you’re sending newsletters. So, I think the takeaway here is to really know your traffic.
Are there any sort of negative situations? Are there times and places when caching should be avoided?
There are certain e-commerce web pages that should never be cached. Caching can be absolutely fantastic in delivering pre-built versions of particular pages. But on a “cart” page, for example, that will be a terrible idea because, if two different people place items in the “cart” at the same time, one could see the other’s stuff. That’s not an accurate example, but that sort of thing can cause trouble. Also, if you use PayPal, which has the instant payment notification, you need to make sure that you’re never caching anything from it. In conclusion, it’s important knowing both your traffic profile and the plug-ins you use.
OK, excellent! Thank you, Richard! See you next time.