B2B Marketing Insights by Ironpaper

Don't forget the Wordpress cache!

Written by Ironpaper | March 10, 2014

Caching is a vital factor in improving a website’s overall performance. In WordPress this is especially true since the CMS creates HTML pages dynamically. PHP code working with MySQL database queries create the live site pages that a visitor experiences.

Wordpress caching can reduce load time by seconds and improve the performance of a website and web hosting server. Shaving off website load time can help improve the user-experience of your site and make search engines happier.

WordPress has an internal cache, and web developers or site owners can install a third-party cache system. All functions of the cache are documented in the Wordpress Codex.  All functions can be found in wp-includes/cache.php file.

WordPress implements two different caching methods.

  1. Non-persistent caching -  The data remains in the cache during the loading of the page.
  2. Persistent caching - Relies on the DB to work.  Cached data can be made to auto-expire with a time setting.

Wordpress cache functions

  • wp_cache_add( $key, $data, $group, $expire )
  • wp_cache_set( $key, $data, $group, $expire )
  • wp_cache_get( $key, $group )
  • wp_cache_delete( $key, $group )
  • wp_cache_replace( $key, $data, $group, $expire )
  • wp_cache_flush()
  • wp_cache_add_non_persistent_groups($groups)

For example: below is the function for resetting the cache:

/**
* @param int|string $key The cache ID to use for retrieval later
* @param mixed $data The data to add to the cache store
* @param string $flag The group to add the cache to
* @param int $expire When the cache data should be expired
*/
wp_cache_add($key, $data, $flag = '', $expire = 0)

Persistant cache plugins

  • W3 Total Cache
  • Memcached Object Cache
  • WP File Cache

Speeding up large, enterprise websites

Below are three simple tips for speeding up larger enterprise websites. For many small websites, caching may be enough to shave off load time. Larger websites may need a little more help, including:

  1. Better server infrastructure: Powerful, clustered servers
  2. Content Delivery Network (CDN)
  3. Configured WordPress Caching

SOURCE: Wordpress Codex: https://codex.wordpress.org/Class_Reference/WP_Object_Cache