Some features of WordPress are less known. WordPress persistent object cache, fragment cache optimisation can improve page loading time. You can setup separate cloud server for cache. All of us possibly aware of XCache, Memcached, Redis. But often how to use remains unknown.
Backend For WordPress Persistent Object Cache, Fragment Cache
In case of Ubuntu 16.04 and PHP 7 for finding the PHP packages run :
apt-cache search php
apt-cache search php*
It is often practical on a running WordPress with different plugins to install all the available PHP packages. There are plugins which are dependent on less used PHP packages and can throw error, like PHP BC Math. It is very difficult to troubleshoot such odd errors.
Of course there are official WordPress documentations and WordPress plugins :
Such cache has the issues like invalidation, storage limits, it is not as simple as full page caching. It is practical to have a cache plugin like WordPress W3 Total Cache Plugin for a general caching and test Fragment Cache for optimisation.
WordPress Persistent Object Cache, Fragment Cache Optimisation
WP Fragment Cache is a good plugin. We have WordPress plugins which enables to use PHP on widgets. Many of the widgets are just HTML content, even link is not important. They are unlikely to have odd errors by sudden wrong in cache. Where such content is, we can add this PHP snippet (while using WP Fragment Cache) :
<?php if ( ! WP_Fragment_Cache::output( $wp_query_or_blockname, $duration ) ): ?>
and where the block of things to be cached ends, we will add this snippet :
<?php WP_Fragment_Cache::store(); ?>
<?php endif; ?>
$wp_query_or_blockname is optional string with default to the line where the call was initiated.
$duration is optional and defines how many seconds to keep the cache for. 0 means the cache will not expire.
only_today will cache one current day. Default is 86400 (one day).
Redis is for the advanced users, Memcached needs some experience but PHP7’s default Zend Opcache needs no expertization. For testing you need no modification and use on only one block. Definitely there is complicated examples :
For such complicated testing, “full page cache” by WordPress W3 Total Cache Plugin should be turned off to avoid conflict of double caching.
As example, out current sidebar’s this text :
Contents are copyright protected and reproduction demands our permission.
PC users can consult Corrine Chorney for Security.
Want to know more about us? Read Notability and Mentions & Our Setup.
Does not need query many times. It is very safe block to test. Testing
RECENT POSTS can decrease load time but needs through monitoring of errors and manual flushing after publication of new posts.
Follow the Author of this article :