There are some startling statistics around website loading times and customer behaviour. Did you know that a huge number of people expect a site to fully load within 2 seconds? And that around 4 out of 10 people will abandon a site if it takes more than 3 seconds to load? As such, WordPress speed optimization is important – and one of the quickest routes to speed is WordPress Caching.
What is WordPress Caching?
Imagine you’re a visitor to your webpage, you click on the link or enter the address for the first ever time and you’re on your way. What’s actually happening here is the browser sends a very small and fast request for information from the server that hosts your site. The server looks at the request and responds by sending the information it’s been asked for back the browser – who in turn displays it as intended.
Now, that information could be quite chunky, meaning the time it takes to be transmitted over ethernet cables and to-and-from a satellite might be fairly slow – and by fairly slow we’re only realistically talking about 7 seconds – but don’t forget, the impatient world of internet traffic means people are tapping their watch if they’ve got to wait more than 3 seconds…
So, this is where WordPress caching comes in. There’s essentially two different kinds – client-side caching and server-side caching. We’ll have a look at how each works in some detail:
If you’ve ever looked at your internet settings, whether on your computer or your phone, you’ll notice there’s a ‘cache’ that can be cleaned. This cache is a bundle of files that have been put there by various websites.
This is because there’s a lot of information that doesn’t change from one website visit to the next. So, visit the BBC news today and when you go back tomorrow morning it’s almost certain that the menus, logos and images that relate to most stories will be exactly the same as they were during your last visit. The site accounts for you being back again and stores a lot of those files in your cache, meaning the page you visit while you drink your morning coffee loads a lot quicker…
Virtually every website does this – and every major browser supports it.
Now, given you have little or no influence over end-user browsing behaviour, server-side caching is how WordPress caching protocols work. They can be broken into 4 different categories:
- Page caching
- Database query caching
- Object-based caching
- Opcode caching
Remember we talked about your website visit actually being a request for information from the hosting server? Well, ordinarily the server would view this with no context, meaning as far as it’s concerned the request is simply for a variety of seemingly unrelated information – with the browser making sense of it when it arrives on your computer or phone.
Page caching means your server remembers the requests it’s receiving – which makes sense given that you’re requesting a page at a time, so, any one request is saved in the server’s hard disk or memory. If the same request is made again, rather than collecting all the files and information again, it has a pre-packaged ‘page’ response ready to fire back – without the need for execution of complex database code.
WordPress sites rely on a massive behind-the-scenes database that stores, updates, orders and handles data in the most efficient manner possible. To make sure information is current the site will interrogate the database periodically. If that data remains the same, rather than continually run the same interrogations again and again (which is effectively the same as re-downloading the information each time) it will save the result of the interrogation in the local storage. This is database caching.
It’s important to have an intelligent tool that manages database caching – this is because the information can change a great deal. The cached information becomes outdated every time you post to your blog, update a gallery or even when a user interacts with some of your site content – perhaps leaving a review or comment. Without a program checking against this database caching can mean irrelevant or incorrect results are returned from the database and displayed on your site.
If you’ve got a site that’s updated frequently it can detrimental to speed to have database caching constantly reconfiguring. Instead, object caching works on user defined elements of the site – for example videos, images or other collections of data that can be defined by a particular name. Even a reasonably popular site with a fair amount of traffic is unlikely to require object caching – as such, it’s a topic to seek professional support with when your traffic numbers are going through the roof…
Okay, back to the accessing a website example. Your request for a webpage is sent, between the hosting server receiving this request and actually returning the information there’s a communication – this is done in a language called PHP. PHP can do a lot of different things, it communicates with databases, serves web content to a browser, receives and sends cookies – and much more.
Although the actual process of PHP execution is a little more complex than we’re giving it credit for here, opcode caching effectively caches the PHP communication, rather than the information itself. Meaning the requests can be re-accessed time and time again.
Caching plugins working alongside other plugins
Now, if you want a headache, getting plugins to work alongside caching plugins is the perfect topic for you! Most server-side caching is done based on updates coming from standard sources – i.e. user data or visitor data. When you have a plugin that say shows your latest Twitter or Instagram post on your page, data is coming from another (and not always compatible) source. Planning on running lots of plugins and a caching plugin? Be prepared for things to need technical tweaking before it runs smoothly!
Overview of WordPress Caching
Caching in its various forms can offer big speed boosts for your site’s visitors. This is vital if you want to ensure you’re getting the absolute most from what can sometimes be extremely impatient users. There are some great plugins out there, look at Hummingbird, W3 Total Cache, WP Super Cache, WP Fastest Cache and WP Rocket for some great features, ease of configuration and use.