Stability & Strategy By Head Random • 2026-12-02 11:22 AM

MTCache Architecture: Multi-Layer WordPress Caching, Dual-Extension WebP SOT & CWV

309.21 ms

Deep dive into MTCache 5-layer caching, dual-extension .jpg.webp SOT with <picture> fallback, keyset batching, /llms.txt ETag, and conflict guard.

MTCache is a purpose-built WordPress and WooCommerce speed extension designed for PolyThemes and Child Themes that cuts server response times (TTFB) while preserving original media assets as immutable Source of Truth (SOT). Combining a 5-layer caching architecture, collision-free dual-extension .jpg.webp/.png.webp conversion (68.41 MB saved across 356 generated copies in live 52-attachment testing), <picture> fallback markup, /llms.txt ETag caching, and an automatic 15+ conflict detector, MTCache optimizes Core Web Vitals (LCP, INP, CLS, TTFB) without risking checkout stability.

MTCache Architecture: Multi-Layer WordPress Caching, Dual-Extension WebP SOT & CWV

Why Multi-Layer WordPress Caching Beats Single-Toggle Speed Plugins

Single-layer HTML caches either miss dynamic ad traffic due to query-string fragmentation or accidentally cache customer-specific WooCommerce states. Separating fragment generation, full-page disk storage, HTTP validation headers, media rewrite safety, and server purge signals allows every visitor tier to get maximum speed safely.

MTCache splits optimization into five focused layers with one-click Master On/Off control:

  1. Fragment Cache Layer (mtcache_remember()): Provides Child Themes and navigation components with O(1) epoch-versioned group invalidation so expensive queries refresh instantaneously when content updates.
  2. Disk HTML + Gzip Page Cache Layer: Writes atomic LOCK_EX .html and .html.gz snapshots, normalizing cache keys by stripping tracking parameters (utm_*, fbclid, gclid, mc_cid) so paid campaign clicks share the fast cached page.
  3. HTTP Validation & Private Bypass Layer: Emits ETag, Cache-Control, and optional OpenLiteSpeed headers (X-LiteSpeed-Cache-Control) for public pages (TTFB <= 800ms, typically 15ms to 45ms on disk HIT) while enforcing BYPASS and private, no-store on /cart, /checkout, /my-account, logged-in admins, and active WooCommerce cart cookies.
  4. HTML, JS Defer & Local WebP CWV Layer: Minifies inter-tag HTML cleanly while protecting <script>, <style>, and <pre> blocks, injects explicit width and height anti-CLS attributes (CLS <= 0.1), prioritizes hero LCP (LCP <= 2.5s) with fetchpriority="high", and lazily defers below-the-fold images (40% to 75% lighter initial payload, INP <= 200ms).
  5. GEO /llms.txt & Smart Purge Layer: Accelerates /llms.txt and multilingual /{lang}/llms.txt endpoints from MTLanguages with strong ETag / HTTP 304 validation, invalidating targeted URLs automatically on post or WooCommerce stock saves.

For deeper server-side crawl mechanics, pair this pipeline with TTFB, server caching, and AI bot crawl-budget optimization.

How Dual-Extension WebP Conversion Preserves Original Images as SOT

Image optimizers that overwrite .jpg or .png uploads, rewrite database GUIDs, or share single .webp extensions across matching filenames create irreversible recovery headaches. MTCache treats original JPEG and PNG files in wp-content/uploads as 100% immutable Source of Truth forever.

WebP Safeguard Mechanism Implementation in MTCache Practical Benefit for Large Stores
Dual-Extension Sibling Naming Writes banner.jpg.webp and banner.png.webp alongside originals Zero filename collision; instant fallback mapping
Byte-Size Guard Discards temporary WebP whenever encoded output is >= original size Prevents bloat on tiny already-crushed icons
Auto-Skip Up-to-Date Files Compares filemtime() before encoding on re-runs Resumes large libraries without wasted CPU
Frontend <picture> Fallback Wraps verified local images with WebP <source> + original <img> Automatic compatibility for legacy browsers & bots
Reversible Restoration Disabling serve toggle or clicking Remove All WebP Copies Restores clean original disk footprint in seconds

During live storefront testing on /shop/, enabling <picture> fallback mode cleanly wrapped all 16 / 16 visible product cards with verified <source type="image/webp" srcset="..."> candidates while keeping original URLs untouched inside <img>. Deleting an attachment via Media Library (delete_attachment) also automatically clears matching .webp siblings so orphaned files never accumulate. See more media principles in WebP and AVIF image optimization for SEO and AI Search.

How High-Scale Batch Conversion Handles Thousands of Product Photos Safely

Running LIMIT ... OFFSET ... loops over 10,000+ WordPress attachments degrades SQL performance and risks PHP timeouts whenever multi-megapixel images appear. MTCache eliminates pagination lag and worker crashes through four engineering safeguards:

  • Keyset SQL Cursor (WHERE ID > last_id): Maintains constant index-backed query speed across 10 or 100,000 attachments while tracking cursor state inside mtcache_webp_queue_state.
  • Soft Time-Budget & Memory Guardrails: Stops a batch cleanly at a 10s execution window or 75% PHP memory_limit threshold, saving exact progress for seamless resumption.
  • Interactive Pause/Resume & Background WP-Cron: Administrators can pause browser batches at any moment or enable the 5-minute WP-Cron queue protected by a 60s transient lock.
  • O(1) Cached DB Statistics: Replaces expensive recursive filesystem directory scans with cached metadata counts (_mtcache_webp_state) for instant dashboard metrics.

Why Built-In 15+ Cache Conflict Detection Prevents Double Optimization Bugs

Running two page-cache plugins simultaneously corrupts nonces, serves outdated prices, or double-compresses HTML into unreadable output. MTCache checks active plugins and foreign advanced-cache.php drop-ins against a registry of 15+ popular caching engines including WP Rocket, LiteSpeed Cache, WP Super Cache, WP Fastest Cache, and W3 Total Cache.

Whenever a competing page-caching plugin is active, MTCache automatically shifts its Page Cache into Standby mode while notifying administrators inside WordPress and the PolyThemes Extensions Hub. Meanwhile, stores running complex filter grids via PolyBlocks retain full WooCommerce dynamic safety.

Frequently Asked Questions

Will turning off MTCache WebP or uninstalling leave broken image links?

No. Original .jpg and .png files and database attachment metadata are never modified. Turning off WebP serving or running Remove All WebP Copies immediately restores original image URLs cleanly.

How does MTCache keep marketing campaigns cached without showing stale WooCommerce carts?

KeyBuilder strips tracking parameters (utm_*, fbclid, gclid, mc_cid, mc_eid) from public URL cache keys while BypassDetector skips caching entirely whenever /cart, /checkout, /my-account, or woocommerce_items_in_cart cookies are present.

Can Child Theme developers vary cache keys by currency or custom query rules?

Yes. Child Themes can filter mtcache_vary_key, mtcache_bypass, mtcache_ignored_query_params, and mtcache_ttl, or wrap expensive components with mtcache_remember().

What happens if Imagick is unavailable on my PHP hosting server?

MTCache probes Imagick WebP support first and automatically falls back to local PHP GD imagewebp() conversion (0 external SaaS API fees), displaying clear capabilities in MTCache -> 3. Image & WebP.

Launch PolyCMS: The Ultimate Open Source Content Management System

Take full control of your website and digital platform. PolyCMS is a modern, developer-friendly, and open-source content management system designed to make publishing effortless. Create blogs, landing pages, custom themes, and extensions - and manage everything from one powerful, unified dashboard.

Why Choose PolyCMS?

  • Free and Open Source: Clean code, zero licensing costs, and complete ownership of your data and platform.

  • Developer First: Fully customizable, extensible with plugins, and built with modern web architectures.

  • Built-in Power: Ready for blogs, static pages, multilingual setup, and seamless SEO customization.

  • Continuous Evolution: As our community expands and we release more themes, extensions, and page builders (MTBuilder), the core system remains completely free.

Get started with PolyCMS today and build without limits. Explore the code on GitHub or read our setup guide.