W ordPress 
Kitchen 2014
Александр Стриха 
alex@pingbull.no
Кеш ирование в 
W ordPress
IsCache = ???
IsCache = 1 
Money
W P_Object_Cache 
wp_cache_set( 'key', 'value' ); 
$value = wp_cache_get( 'key' );
function get_free_products_count() 
{ 
if ( false === ( $count = wp_cache_get( 'free-products' ) ) ) { 
$count = big query 
wp_cache_set( 'free-products', $count ); 
} 
return $count; 
} 
get_free_products_count(); // SQL 
get_free_products_count(); // Cache 
get_free_products_count(); // Cache
wp-content/object-cache.php 
Memcached 
https://wordpress.org/plugins/memcached/ 
Redis 
https://github.com/ericmann/Redis-Object-Cache
Transients API 
set_transient( 'key', 'value', $time ); 
$value = get_transient( 'key' );
if ( false === ( $value = get_transient( 'key' ) ) ) { 
$value = wp_remote_get( $url ); 
set_transient( 'key', $value, DAY_IN_SECONDS ); 
}
if ( false === ( $value = get_transient( 'key' ) ) ) { 
$value = BIG QUERY 
set_transient( 'key', $value, DAY_IN_SECONDS ); 
}
add_action( 'save_post', function ( $post_id ) { 
delete_transient( 'key' ); 
});
if ( false === ( $value = get_transient( 'key' ) ) ) { 
ob_start(); 
get_sidebar(); 
$value = ob_get_clean(); 
set_transient( 'key', $value, DAY_IN_SECONDS ); 
}
add_action( 'cron_event', function( ) { 
$value = wp_remote_get( $url ); 
set_transient( 'key', $value, DAY_IN_SECONDS ); 
});
Advanced Cache 
wp_cache_postload( );
wp-content/advanced-cache.php 
define( 'WP_CACHE', true ); 
WP Super Cache 
https://wordpress.org/plugins/wp-super-cache/ 
W3 Total Cache 
https://wordpress.org/plugins/w3-total-cache/ 
Batcache 
https://wordpress.org/plugins/batcache/
function wp_cache_postload( ) { 
$key = 'page_cache' . $_SERVER[ 'REQUEST_URI' ]; 
if ( $html = get_transient( $key ) ) { 
echo $html; 
exit; 
} 
oobb__start( function( $html ) use ( $key ) { 
set_transient( $key, $html, HOUR_IN_SECONDS ); 
return $html; 
}); 
}
Response time (sec) 
Clean W P: 99 
Object Cache: 116 
Full Page Cache: 1
KEEP 
CALM 
AND 
USE 
CACHE

WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress