When it comes to web performance, WordPress caching 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.
What is WordPress Caching?
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 pageview.
Why you should you cache? That’s simple, cacheÂ makes WordPress websites faster and reduces load on a web server. This is why every site should enable 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 to your WordPress host.
No WordPress Caching Plugins Needed at Kinsta
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:
- Bytecode cache
- Object cache
- Page cache
- CDN cache
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.
Don’t Take Our Word For It
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.
migrated a site onto @kinsta that got over 1mil pageviews yesterday with around ~1500 active users all day. performed incredibly well ð
â Ben Word (@retlehs) October 27, 2017
â Neuralab (@Neuralab) July 22, 2017
â Martin Caparrotta (@MartinCap) April 16, 2017
â Palash Bakshi (@ppbakshi) September 11, 2016
â Lucian Florian (@fldtrace) May 17, 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 ensure customers make the best use possible of caching for the best possible performance possible.
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, and 7.1 (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
When HHVM is enabled on a Kinsta-hosted site a file named object-cache.php is added to
/wp-content/. This file enables HHVM to use Alternative PHP Cache (APC). Object caching is only enabled on Kinsta when a site is set to use HHVM,Â which can easily be selected in the MyKinsta dashboard (as seen below).Â This can also beÂ enabled via a plugin like WP Rocket or W3 Total Cache.
Enterprise 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. WP Tavern has a great article on persistent object caching 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:
- Much faster pageloads.
- Dramatically reduced server loads and the ability to handle dramatically more traffic as a result.
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:
- It reduces the server resources required to load a website. Since the CDN is doing the work, the web server doesn’t have to.
- It allows resources to be delivered from locations all around the world, speeding up website performance for users who are geographically distant from the server hosting the website.
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:
- Standard CDN: Kinsta CDN (KeyCDN), Stackpath, Cloudfront.
- CDN plus security: Cloudflare, Sucuri, Akamai (optionally).
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.
- Sucuri setups up full page cache if the cache level is set to “Enabled.”
- Cloudflare requires page rules to be set up for full page cache to work. The rules must utilize a “Cache Everything” cache level.
Kinsta Cache Response Header
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:
- Enable Compression (Kinsta already has Gzip enabled on all servers, no need to enable)
- Reduce server response time (Kinsta is already blazing fast, already well within Googleâs acceptable parameters without any optimizations)
- Expires Headers (No need to enable because Kinsta has caching headers enabled at theÂ server-level)
For example, our test site scores a 100/100 on PageSpeed Insights without any caching plugin enabled. The WordPress caching isÂ all handled by Kinsta at the server level.
Kinsta Cache Settings
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 My Kinsta dashboard, or utilize the Kinsta cache plugin.
Clearing WordPress Cache
ToÂ manually clear your full page cache, you can do so from within the My Kinsta dashboard. Simply click into your site, click into tools and click on the âDelete Page Cacheâ button.
Kinsta Cache Plugin
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 My Kinsta 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 caching 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 3 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.