B2B Articles
March 10, 2014
By:Ironpaper

Don't forget the Wordpress cache!

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

Interested in working for or partnering with Ironpaper? We’d love to hear from you.
We are passionate about helping remarkable companies grow. We solve challenges that hold businesses back. We love it. 
Connect with Us