Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
WordPress Theme Development

WordPress Caching and Themes

Make themes cache-friendly and use transients for expensive theme modules.

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

Leave a reply

Your email address will not be published. Required fields are marked *