How to Improve WordPress Speed with Caching

In the WordPress space, caching is a word that gets used a lot. You’ll have seen caching plugins like WP Super Cache in the WordPress plugin repository and it’s sold as the silver bullet to making WordPress work faster and more efficiently.

It takes more than a cache to have an efficient WordPress website – but a cache certainly will help.

Before you launch in and start downloading WP Super Cache let’s step back and take a look at caching and what it will and won’t do for you.  It’s essential to have a basic knowledge of the limits of caching and when it’s appropriate to use, and importantly where you should avoid it.  This series of primer articles should help you get up to speed quickly.

Let’s start with a definition of what a cache is.

A cache is… “a temporary location on your WordPress server and your local device that holds assets that belong to a website.”

By this definition, you can already see that there is more than one place where content can be cached. The dictionary is also useful to understand the origin – it talks about a hidden place, that’s useful too because caching is often invisible to users, except that they enjoy faster download speeds.

Let’s go back to those two locations for a cache and we’ll talk about both – there are server-side caching and browser-side caching which happens on a web visitor’s browser.

With browser-caching, a copy of the website is stored on the user’s computer when they first browse a particular website.   It’s stored in a location called a browser cache.  HTML files, stylesheets, images and other media assets are all stored on the user’s hard drive.

They are stored there so that the next time that person visits your website, their browser already has many of the files it will need to display your site on their computer already.  This saves effort on your server and also means the visitor doesn’t have to wait for duplicate website assets to be downloaded for display.

So let’s dig into the detail.

When you visit any WordPress website, a few things happen.  After typing the URL on your browser it is sent as an HTTP request to the web server.  After getting the request, the server passes it to PHP which manages the request. PHP requests website information from a database and the database responds with the information PHP needs to display your site.  PHP then assembles that information into a static HTML webpage and sends it back to the server. Your server then sends all the information back to your browser.

When you think about it, there’s a lot going on in your server to display a simple webpage. Now imagine that happening for every page on your website for every visitor and you’re starting to see how one website could generate a lot of load on a server especially during busy periods.

Browser-caching solves part of the problem – at least for repeat visitors. It can help speed things up and bypass all that database processing by serving a locally cached version of the site.

Now think about those sites where content is constantly being updated.  Browser caching only helps when visitors have already visited the site, but it doesn’t improve performance if it’s a user’s first time to the site, or first time seeing new information.

When your site has updated content, the browser still must engage the server to display that new content.  During quieter periods, the requests will generally be returned quite quickly. But, when the traffic scales up, bottlenecks can appear, which slows down the server and it can appear like a website are performing very slowly.  Sometimes websites will continue to consume all the resources until a website crashes.

This is where server-side caching is vital. By installing a caching plugin on your website, you can replicate the positive impacts of the browser caching but on your server.  This works by intervening in requests to your web-server and passing an already cached version of a web page an eliminating the need to go to the database for every request.

So if 15,000 visitors go to a particular page on your website site, instead of requesting that page 15,000 times, the server will make that request once, then send the cached copy of the page to the remaining 14,999 users.

So you can see how server-side caching can really make a difference to your website’s performance. Not only is it saving requests to your web server, but pages can be served faster, because your website is picking up a copy of the page and sending it, rather than building a new page each time it is requested.

But what happens when pages are updated?  Will visitors see them?

Yes.  The good news is that server-side caches can be controlled, so users will always see new content. Our examples to this point have been quite simple to explain the concept, so let’s dig in even deeper.

Caches are controlled using rules that manage what should be cached, how long copied files are served before being refreshed, and under what conditions the entire cache should be refreshed.

Every website consists of static and dynamic content. Static content is things like post images, CSS style sheets, and javascript that don’t change often. These can be cached for longer periods of time. Similarly, when you’ve got content that changes frequently you can set your cache to expire more often, or set a rule to delete cached files on each update.  Examples of this might be news sites with live news feeds, e-commerce sites, or membership sites where you have member profile pages that need to display member-specific information directly from the database.

Even ‘old’ cached content doesn’t stick around before the cache resets, but the positive impact it can have on your website performance far outweighs any immediacy issues.  Even a conservative server-side cache setting of 10-minutes will give you an incredible performance boost, without affecting what your website readers see.

Generally, if you need to see changes immediately, most caches have a ‘flush’ button – which will completely delete the cache, forcing the server to get fresh content from the server.

If you want help establishing caching software on your WordPress site, Asporea can help.  You might also consider our WordPress protection plan to help manage your site, and we’ll install caching software and other performance-boosting measures for free. Check out our WordPress Protection Plan for more details.

Share on facebook
Share on twitter
Share on linkedin