When it comes to web performance, WordPress cache is just one of those things that every site owner has to deal with at one point or another. We love WordPress, but it’s definitely not the fastest platform, especially if you compare it to a completely static site. One reason for this is simply because it’s built on PHP which can only execute things so fast. We saw some massive improvements with PHP 7, but if you don’t properly cache your site it can still come to a crawl.
Wouldn’t it be nice if you didn’t have to worry about figuring out which caching plugin is the best? Well, here at Kinsta, we take care caching for you, so you can focus on growing your business.
Caching is the process of storing resources from one request and reusing those resources for subsequent requests. Basically, it reduces the amount of work required to generate a page view.
Why should you use cache? That’s simple, caching makes WordPress websites faster and reduces the load on the web server. This is why every site should strive to use as much caching as possible. In addition, in the case of CDN caching, it also reduces the amount of server bandwidth required to generate a pageview by storing static resources external from that of your WordPress host.
That’s right! If you host your WordPress site with Kinsta you don’t need to worry about messing with any complicated and confusing caching plugins. That is because we have different types of caching already implemented. You can finally stop Googling around for the “best caching plugins of 2017” and focus on more productive tasks.
At Kinsta, we utilize the following four types of cache, which are all automatically done at the software or server-level:
Many of our customers report over 45% decreases in load times simply by migrating to Kinsta. And these are WordPress sites that previously had caching plugins installed. Below is an example of a site that was moved to Kinsta. Before it was getting spikes well over the 1-second range, and after moving to Kinsta (and deleting the caching plugin) it stayed consistently under 500 ms.
There are other variables involved in those load time decreases as well, but caching is a huge part of it. We aren’t saying all caching plugins are bad, in fact, many times it is due to the user not configuring the caching plugin correctly, which in turn slows down their WordPress site. Have you ever tried configuring W3 Total Cache? It can get downright confusing pretty quick.
And as far as performance goes, don’t just take our word for it, check out some of these testimonials from people who have migrated to Kinsta. All of which no longer use caching plugins.
— WPColt (@WPColt) January 3, 2018
— Neuralab (@Neuralab) July 22, 2017
— Martin Caparrotta (@MartinCap) April 16, 2017
— Palash Bakshi (@ppbakshi) September 11, 2016
Now let’s dive into each type of WordPress cache you’ll run into on a regular basis here at Kinsta. Understanding what each layer of caching does will help you troubleshoot issues related to cache and ensures your site will run smoothly.
Bytecode cache stores compiled PHP code so that the next time it is used the compilation step can be skipped. At Kinsta, we have enabled OPcache in PHP 5.6, 7.0, 7.1, and 7.2 (and will enable it in newer versions of PHP as they are released on our platform).
When a PHP file or script is processed it first has to be compiled into machine-readable opcode. What OPcache does is store the converted opcode so that PHP will be able to skip the compilation step the next time that specific file or script is needed. Using OPcache significantly improves the performance of PHP. However, it means that changes to PHP files are not reflected immediately. For this reason, OPcache is disabled on Kinsta staging sites.
Read more about how OPcache speeds up PHP applications.
Object cache stores the results of database queries so that the next time that particular bit of data is needed it can be delivered from cache without querying the database. This speeds up PHP execution times and reduces the load on your database.
WordPress has a built-in object cache:
WP_Object_Cache. However, this object cache only stories objects for a single page load. The purpose of the cache is to make sure the database isn’t queried in the exact same way multiple times during a single pageload. However, cached objects aren’t used after that single pageload. While this is a useful feature in WordPress, object caching is much more powerful if the cache objects can be used between multiple pageloads.
You can change this behavior and reuse cached objects for multiple pageloads by switching from WordPress’ built-in object cache to an external solution. This is done by dropping a caching script into the
/wp-content/ directory. There are plugin-based object cache options such as W3 Total Cache and WP Rocket that do this by adding an advanced-cache.php file to
Our clients at Kinsta can also purchase our Redis add-on and have it installed alongside PHP 5.6 or 7.0. Redis is an open source, in-memory data structure store, used as a database, cache and message broker. Check out our article on how to use Redis as a persistent object cache if you want to learn more.
Page caching stores the entire HTML of a page so that subsequent pageviews can be generated without WordPress having to generate the page.
When you load a WordPress website, WordPress has to process a large number of PHP files and query the database a number of times. For pages that aren’t constantly updated, this is wasted effort. It is much more effective to generate each page just once, then store that page and deliver the subsequent visitors. This is what page caching does.
The benefits of page caching include:
Here a Kinsta, our servers use the
nginx fastcgi cache module for page caching. And it is set to expire every 1 hour by default. However, clients can contact us if they need to increase or decrease this duration.
The page cache is configured to work right out of the box with standard WordPress, BuddyPress, WooCommerce, and Easy Digital Download sites. You don’t have to do a thing! Simply launch your WordPress site and page caching will start happening. However, customization may be needed if you use a customized URL structure or veer far outside the typical WordPress setup.
Like bytecode caching (OPcache), page caching is completely disabled on Kinsta staging sites.
A content delivery network (CDN) offers two primary benefits:
There are two basic types of CDNs: those that are simply CDNs and those that offer a CDN along with security features. A few common examples of each include:
The first type of CDN is set up by creating CDN URLs which are used to access the website resources. The exact way this is enabled varies from one CDN to the next. The basic idea is that URLs for static resources will be changed to the CDN URL so that the resources are pulled from the CDN. A standard CDN typically only caches static files like JS, CSS, and media files. Our Kinsta CDN is a standard CDN powered by KeyCDN.
The second type of CDN serves as a full proxy server. What this means is that every request has to go across the provider’s servers before arriving at Kinsta’s servers. This is enabled by using the CDN provider’s nameservers, so that the CDN provider has full control of the website DNS. This allows the provider to do a lot of things that a simple CDN cannot do, such as filter out traffic from bad IPs, offer DoS/DDoS protection, or even store a full page cache out on the CDN.
If you are using a proxy server CDN such as Cloudflare or Sucuri, you have the ability to create a complete page cache out on the CDN. The use of a CDN like Cloudflare or Sucuri to cache full page html completely offloads all of the work from our servers and is an excellent solution for a site that expects to see a massive surge in traffic.
You can test to see if your page is being served from Kinsta cache by looking at your HTTP response headers. Kinsta adds a
X-Kinsta-Cache header. Upon first request to a non-cached page, it will display
MISS, as seen below.
Upon the second request to the same page, the
X-Kinsta-Cache header value will show a
HIT, meaning it is being served from cache.
And if you read our article on scoring 100/100 in Google PageSpeed Insights, you will know that Kinsta also has additional server level optimizations to automatically fix the following warnings you might be familiar with:
For example, our test site scores a 100/100 on PageSpeed Insights without any caching plugin enabled. The WordPress cache is all handled by Kinsta at the server-level.
You might be wondering now, how to control the cache at Kinsta. There will be times of course when you need to clear it, especially when troubleshooting. You have a couple of easy options. You can clear your cache from both the MyKinsta dashboard, or utilize the Kinsta cache plugin.
To manually clear your full page cache, you can do so from within the MyKinsta dashboard. Simply click into your site, click into tools and click on the “Clear Cache” button.
The second option you have is to use the Kinsta cache plugin. What? Yes, technically it is a cache plugin, but it is not your typical caching plugin, as it works on a server-level.
By default, the Kinsta Cache is a plugin installed on every site that is hosted by us and is available from the left-hand side of your WordPress admin dashboard. This is used to intelligently clear the cache on appropriate pages of your website. The plugin is required to ensure your site runs smoothly in our environment. Also, remember that the page cache expires every 1 hour by default.
The plugin also allows you to purge the cache right from your WordPress admin bar. This would probably be one of the biggest reasons to use it, as you won’t have to jump over into the MyKinsta dashboard. You can do it right from your site.
It also allows you to setup custom caching rules. Depending on how your site’s configuration, additional caching rules might be needed. You can add custom paths to purge whenever your site is updated.
Hopefully, now you understand a little more about WordPress cache and the four different types you’ll run into on a regular basis here at Kinsta: bytecode caching, object caching, page caching, and CDN caching.
If you’re tired of messing with typical WordPress caching plugins and simply want a fast site right off the bat, we recommend you give Kinsta a try! There is a reason we’ve been awarded “top tier” status in WordPress performance 4 years in a row by ReviewSignal. And that is because our servers are fine-tuned on top of Google Cloud Platform for lightning fast load times. You won’t be disappointed in our performance.
Send this to a friend