We recently completed several enhancements to our caching system on the WordPress Hosting platform and I wanted to take a moment to address them all at once. The following is an overview of the new and improved setup that includes performance and control improvements. This is now live on all of our WordPress Hosting accounts.
The WordPress Hosting has multiple layers of caching:
- Full Page Caching (Provided by Nginx Fast-CGI cache)
- Object Caching (Provided by Redis)
- PHP function caching (Provided by OpCache)
- DB Query caching (Provided by Mariadb)
For the most part, these all operate seamlessly and provide a substantial performance boost to sites on the WordPress Hosting.
Full page caching changes
Most of the recent work has been around the full page cache wherein some very unusual setups we were finding that certain activities in the WordPress admin area caused sites to become unresponsive. This was due to the fact we automatically clear the cache after a variety of activities, including when a post is edited. Unfortunately, some actions can cause multiple posts to be edited at the same time, in turn causing the cache to be constantly clearing itself and taking up too many resources. This chain of events could lead to site instability in some situations.
To avoid this we have modified automatic cache clearing; instead of purging the cache on every request, we now schedule a WordPress event to clear the cache. So now when a clear is needed, we check if there is one scheduled and if there is not, add one to a queue. This change does mean that it can now take up to 5 minutes for automatic cache clearance to occur.
It’s important to remember that as a logged in user, you will not see cached pages and it is only non logged in visitors who hit the cache. You can also press the Clear Cache button within your WordPress admin or 34SP.com client control panel and this will instantly clear the cache with no wait time, at any time.
To make this even easier we have added a Clear All Caches button that is now available in the WordPress admin toolbar, under hosting tools. Clicking this will:
- Clear the Full Page Cache
- Clear the Object Cache
- Clear the OpCache
This new button is available by default to admin role users with the “manage_options” capability, however, you can change who has access by modifying the “tfsp_enable_admin_bar” filter; simply filter to true for scenarios that you wish to have access.
If the full page cache is disabled the new admin toolbar will also not show to avoid confusion; you can enable caching via Tools->Hosting Tools and clicking enable cache.
Disabling object cache
From time to time plugins have issues with the object cache – this normally happens where the plugin attempts to write something to the cache, then read from the database. A common scenario where a plugin stores something in a transient, then edits a page which triggers an object cache flush and now doesn’t have the content that was in the transient.
While we don’t recommend it, for certain plugins the only way to get them to function until they are updated is to disable the object cache you can do this by adding the following to your my-config.php
This will turn off the object cache entirely. Again, we don’t recommend this unless you’re an advanced user who understands the impact to your account.
Auto tuning OpCache
We get an occasional support ticket regarding changing settings for OpCache. While our OpCache settings out of the box are perfect for the vast majority of sites, larger sites do need further tweaks. With this in mind have now written a dedicated auto-tuner that nightly looks at the number of PHP files and tweaks settings automatically for maximum performance. This means that sites that are always getting the best out of OpCache out of the box and without the need for further tweaks, which would be overwritten by the auto tuner.
This set of changes should see a small improvement in performance for everyone, while also providing further stability for everyone on the platform.