iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

Performance / Caching

WordPress performance work pays compound interest — every optimisation helps every page, on every device, for every visitor. The pyramid: hosting, full-page cache, fewer plugins, optimised images, lazy-loaded above-the-fold content, and a real CDN. Most slow WordPress sites are slow because of two or three plugins; the rest is incremental.

A performance audit + the fixes that actually move the needle

EXAMPLE
# 1) Measure first. Always.
#   - PageSpeed Insights:  field + lab data with CrUX
#   - WebPageTest:         filmstrip + waterfall, RUM-friendly
#   - Query Monitor (WP plugin): per-page DB queries, slow PHP, hooks

# 2) Hosting — the cheapest 200ms you will ever buy
#   PHP 8.3+ with OPcache enabled (php.ini):
#     opcache.enable=1
#     opcache.memory_consumption=256
#     opcache.max_accelerated_files=20000
#     opcache.validate_timestamps=0      ; production only; flush on deploy
#   MySQL 8 / MariaDB 10.6+, innodb_buffer_pool_size ~70% of free RAM
#   nginx in front, with FastCGI cache for anon users

# 3) Full-page cache — the single biggest win for anon traffic
#   Plugins: WP Super Cache, W3 Total Cache, LiteSpeed Cache, WP Rocket
#   At nginx level — bypass PHP entirely for cached pages
# server {
#   set $skip 0;
#   if ($request_method = POST) { set $skip 1; }
#   if ($query_string ~ '.+')   { set $skip 1; }
#   if ($http_cookie ~ '(comment_author|wordpress_logged_in|wp-postpass)') { set $skip 1; }
#   location / {
#     try_files /wp-content/cache/page_enhanced/$host$uri/index.html \
#               /wp-content/cache/page_enhanced/$host$uri/index.html.gz \
#               @php;
#   }
# }

# 4) Plugins — every active plugin runs on every request
#   - wp plugin list --status=active --format=count   # know the number
#   - Audit: keep the 5-10 that add real value; drop the rest
#   - Watch for plugins that enqueue assets on EVERY page (sliders, contact forms)
#   - Use Asset Cleanup or Perfmatters to scope assets per-route

# 5) Images — usually 70% of page weight
#   - Native: <img loading='lazy' fetchpriority='auto' decoding='async'>
#   - WebP / AVIF: Imagick / GD with a plugin (EWWW, ShortPixel)
#   - Responsive: <picture> + srcset + sizes
#   - max-width in CSS does NOT shrink the download — the browser pulls the full byte stream

# 6) Lazy load below-the-fold and embeds
#   - YouTube / Vimeo embeds via 'lite-youtube-embed' style facades
#   - 3rd party scripts (analytics, chat): defer or load on idle

# 7) Database hygiene
#   wp transient delete --expired
#   wp post delete --post_type=revision --force $(wp post list --post_type=revision --format=ids)
#   OPTIMIZE TABLE wp_options;  -- shrinks autoload bloat

# 8) HTTP caching headers for assets
# location ~* \.(?:jpg|jpeg|png|webp|avif|svg|woff2|css|js)$ {
#   expires 1y;
#   add_header Cache-Control 'public, immutable';
# }

# 9) CDN — Cloudflare / BunnyCDN in front of nginx
#   - Anon HTML cached at the edge (Cache Everything + Bypass cookies for logged-in)
#   - HTTP/3 + Brotli compression
#   - Image resizing at the edge for the biggest wins on mobile

# 10) Things that often DO NOT help much
#   - Minifying HTML inline (tiny win after gzip/brotli)
#   - 'Database optimisation' plugins on tiny sites
#   - Page-level critical CSS plugins that break layout for a 5ms win

Why it matters

OPcache + a real page cache covers ~80% of WordPress performance work. The remaining 20% is image weight and over-active plugins. Resist the temptation to start with "performance plugins" — they layer caches and minifiers on top of the same bottleneck instead of removing it.

Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.

Example

Example
# Cache plugin (W3 Total Cache, WP Rocket), CDN, lazy-load images, image optimisation.
Try it Yourself »

Discussion

Loading…