It’s the third in our series of chats called the A-Z of WordPress, where we attempt to cover all the major aspects to building and maintaining sites with WordPress.
Today, it’s the letter ‘C’ for Caching (including server side caching, front end caching (plugins) and CDNs. However, we avoid getting too deeply into page load times and scores, which we cover separately on another podcast.
Here’s a definition…
In computing, a cache is a hardware or software component that stores data so that future requests for that data can be served faster.
Wikipedia
WordPress has to process PHP and query a database to be able to serve a web page to visitors. On the frontend, this is seen as the time to first byte TTFB. (the level above for Google being the First Contentful Paint – FCP).
This is fairly insignificant if running WordPress with a lightweight theme on a reasonably powered server (with not too many concurrent users.
But many are running resource heavy Page Builders, backups, security plugins, forms plugins, along with other heavier plugins like eCommerce, LMS, memberships, bookings, etc. They all add to the number of processes and queries.
When the visitor hits the site, serve them a stored HTML version of the page. The instruction being in the .htaccess file.
With WordPress now being more people than ever, and many wanting to be ‘code free’ whilst still maintaining high speed expectations, serving a stored (cached) HTML file seems like a good idea.
Page Builders only add to the amount of processing required. PHP 7 seems to process things almost twice as quickly as PHP 5.6, but memory_limits have typically gone up from 128MB to 256MB, with more often needed.
Is dynamic content. Things get added to a cart, there are check out pages, content needs to be personalised, and this does not sit well with a cached page.
Caching often creates a false sense of security. Folk apply all sort of measures and services like Nitropack to achieve 100% Google insight scores, but is this just a case of polishing a turd?
So, if you’ve been in the WordPress space for any length of time, you’ll know that there’s a host of plugins available to help you out with caching. Some focus on caching – some on caching and other optimisations (lazy loading, minifying and combining CSS and JS (JS deferring too is used).
Here are some that we’ve heard of:
What most of these do is respect the Cache-Control: no-cache wrapped in to dynamic area of what a plugin outputs. An example would be something like WooCommerce.
Bytecode cache stores compiled PHP code so that the next time it is used the compilation step can be skipped. This should be off during development.
Example APC – Alternative PHP Cache
Object cache stores the results of database queries so that the next time that a particular bit of data is needed it can be delivered from the cache without querying the database. This speeds up PHP execution times and reduces the load on your WordPress database.
Example – Memcached
Varnish is an HTTP accelerator. Varnish stores data in virtual memory and leaves the task of deciding what is stored in memory and what gets paged out to disk to the operating system.
Storing asset on server closest to the visitor:
Litespeed is privately owned (it’s the only one to support HTTP/3).
LiteSpeed Cache (LSCache) for WordPress has one million+ active installations!
It’s an all-in-one acceleration plugin, with its signature feature powered by LiteSpeed Web Server’s built-in server-level cache. This built-in cache simplifies the server stack and makes for a faster, more efficient way to serve content. The LSCache plugin adds built-in PageSpeed optimisation, an image optimisation service, critical CSS generation service, third-party CDN integration, among other features.
There are hosting companies that will flatten all of your WordPress website so that the pain of setting up and maintaining all of this technology is done for you. Here’s some examples:
This is all very complex isn’t it? It’s the sort of thing that either makes you run away or get stuck in.
The bottom line is that there’s no ‘right’ way to think about this. There’s just a bunch of options. Whatever you can do to speed up your website is certainly worth doing, and we hope that some of the links included in this post might give you some starting points.
As always, we’d love to hear your comments, either in the comments thread below, or in the WP Builds Facebook Group, where you can find the thread.
[spp-player url="https://episodes.castos.com/wpbuilds/37.mp3"] This weeks WordPress news - Covering The Week Commencing 29th October 2018: WordPress 5.0 Beta 2WordPress 5.0 Beta 2 is now available!...
0.75x 1x 1.25x 1.5x 2x 0:00... 217 – Get your WordPress tasks in order with DocketWP Interview with Andre Gagnon, Kyle Van Deusen and...
0.75x 1x 1.25x 1.5x 2x 0:00... 39 – Adam Hempenstall from Better Proposals PRIZE ALERT 1 years premium membership on offer – Adam has...