WordPress Caching and Themes — a practical guide to WordPress theme caching with clear examples you can reuse in real projects.
WordPress Theme Development Series (75/96). Prefer one article? Read the complete WordPress theme development tutorial.
Short description
Avoid personalized markup in fully cached pages without ESI/AJAX strategies.
Transient for menus-like data
$html = get_transient('acme_footer_html');
if (false === $html) {
ob_start();
// render expensive section
$html = ob_get_clean();
set_transient('acme_footer_html', $html, HOUR_IN_SECONDS);
}
echo $html; // phpcs:ignore if trusted generated HTML