📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials WordPress Development WordPress Performance

WordPress Performance

5 min read Quiz at the end
Transients, object cache, efficient WP_Query (fields=ids, no_found_rows), and caching plugins.

WordPress Performance

// Transients (DB-backed cache with TTL)
$data = get_transient('popular_posts');
if (!$data) {
    $data = expensive_query();
    set_transient('popular_posts', $data, 12 * HOUR_IN_SECONDS);
}

// Object cache (Redis/Memcached)
$data = wp_cache_get('key', 'group');
if (!$data) {
    $data = expensive_query();
    wp_cache_set('key', $data, 'group', 3600);
}

// Efficient WP_Query
new WP_Query([
    'fields'        => 'ids',     // only get IDs
    'no_found_rows' => true,      // skip COUNT query
    'update_post_meta_cache' => false,
    'update_post_term_cache' => false,
]);

// Avoid queries in loops
// Bad: get_post_meta inside while loop
// Good: WP prime_post_caches before loop

// Plugins: WP Rocket, W3 Total Cache, Redis Object Cache