Contact
Site: US UK AU |
Nexcess Blog

WordPress Caching: How Does Caching Make WordPress Sites Faster?

June 21, 2018 0 Comments RSS Feed

How caching makes WordPress Sites FasterAll dynamic content management systems and eCommerce applications — WordPress included — generate HTML pages by executing code and making database requests. The process typically takes fractions of a second, but in some cases it can take several seconds and consume a lot of server resources on a busy site. One of the ways we can make the process faster and reduce server load for a WordPress site is caching.

 

What Is the Purpose of Cache Memory?

Conceptually, caching is quite simple: generated data — web pages, database objects, byte code — is saved so that it doesn’t have to be regenerated every time it is needed. If the same data is needed more than once, it is wasteful to generate it again when the pre-generated version can be used instead.

Although it is simple in theory, in practice, caching and deciding what not to cache, is one of the most difficult problems in computer science (according to a famous joke, the other difficult problem in computer science is naming things).

A well-optimized WordPress site uses many different types of cache, and to gain some insight into WordPress performance optimization, it’s interesting to consider some of the ways that WordPress caches data.

Total Cache W3 WordPress Settings

To Create WordPress’ Fastest Cache

We use the WordPress caching plugin W3 Total Cache by default. If you would like to make changes to the W3 Total Cache settings, you can do so through your WordPress admin panel. Here, you have the option to change how your WordPress site handles cached information and improving performance for your site. 

PHP Caching

WordPress is a PHP application. Caching aside, every time you load a WordPress page, PHP code is executed. Executing PHP can be expensive because the code has to be loaded, parsed, and run. To reduce the time it takes to execute PHP code, a PHP accelerator can be used to cache PHP bytecode rather than generating it from the source code every time it is needed.

We use eAccelerator for PHP caching on most WordPress hosting plans and APC on clusters.

The WordPress Object Cache

The WordPress Object Cache is part of WordPress. It caches the results of expensive operations like complex database queries. The object cache is transient: it only caches data for the length of a response, so if we want a more persistent cache, we add a caching plugin into the mix.

Object Cache in Total Cache 3 for WordPress

Object cache options in W3 Total Cache.

With W3, it can be enabled with just a click. For Object Cache Method, we recommend leaving the method at the default ‘Disk’. If you are running multiple servers, Memcached is also a good solution.

Memcached

Persistent caching to disk is nice, but even the fastest disks are slower than RAM. Memcached is a popular “high-performance, distributed memory object caching system”. It provides an in-memory key-value store, which allows cached objects to be retrieved more quickly than if they were stored on disk.

Nexcess uses Memcached with W3 Total Cache on our performance-optimized WordPress hosting plans. We’ve found this provides the largest performance boost.

Persistent Object Caching

WordPress caching plugins like W3 Total Cache do a lot more than object caching, but one of their most important tasks is persistent object caching. Unlike the WordPress Object Cache, cache plugins will cache objects to disk.

There are numerous plugins available for handling persistent caching, many of which are recommended by WordPress themselves.

Page Caching

Page caching is just what it sounds like: when a page is generated it is cached so that it doesn’t have to be regenerated next time it is requested. This data is usually stored in RAM, as opposed to the hard drive. This is because RAM is much faster than hard drive speeds. W3 Total Cache provides full-page caching.

Page Cache in Total Cache 3 for WordPress

Page cache options in W3 Total Cache.

Page caching is also sometimes known as disk caching. With WordPress, page caching is a relatively simple procedure and just requires the site admin to enable it. This can be done by ticking the checkbox in the plugin settings. 

Browser Caching

Browser caching occurs after a WordPress site has sent HTML, JavaScript, CSS, and images to a browser. Much of that content doesn’t change between page loads and the same content is shared between many pages. It doesn’t make sense to download JQuery, for example, every time a visitor opens a blog article. The browser will cache this content so that it can load and display pages more quickly.

Browser Cache in W3 for WordPress

Browser cache options in W3 Total Cache.

Increase WordPress Cache Performance

We’ve briefly looked at six types of caching here and gone through the WordPress caching plugin W3 Total Cache. In reality, there are many more levels, from caches on the server’s processor to external caching tools like Varnish, but hopefully, we’ve given you some idea of the complexity that lies behind a fast WordPress site.

For more information on how to adopt WordPress’ fastest cache, get in touch with our team and see how we can help you to optimize your WordPress hosting. Also, don’t forget to see what WordPress has planned for the future and check out our WordPress Gutenberg guide.

Posted in: Nexcess, WordPress