Skip to main content
KadiCache
Browse 37 Docs Guides & Search

WordPress Multisite Network Setup, Subsite Isolation & Governance

Configure subdomain and subdirectory WordPress Multisite networks with isolated per-blog Early Cache directories, safe background queues, and shared network configuration.

Bootstrap/NetworkEarlyCache.phpCache/Delivery/NetworkEarlyMap.phpAdmin/NetworkWorkspace.phpBootstrap/NetworkSiteRetirement.php
WP Admin -> KadiCache -> Dashboard (Dark)
MODULE 05 · 2X RETINA
Dark-theme workspace engineered with persisted pre-paint theme state and zero FOUC.2880×1840 WebP
Quick Summary · 30-Second Operational SpecSource-Verified Guide
WP Admin Path
WP Multisite -> Network Admin -> KadiCache
Expected Outcome
Strict Per-Blog Isolation · Zero switch_to_blog() Plugin Bleed
Key Marker / Engine
NetworkEarlyCache.php | NetworkEarlyMap.php | NetworkWorkspace.php
  • Supports subdomain (de.example.com), subdirectory (example.com/de/), and custom domain-mapped WordPress Multisite installations out of the box (NetworkEarlyMap.php).
  • Isolates every blog_id into its own cache namespace, early snapshot, background preload queue, and subsite-scoped Object Cache epoch (wp kadicache object-cache flush --blog=<id>).
  • Never executes subsite plugins inside switch_to_blog() (NetworkWorkspace.php)—queuing site-local operations safely behind advisory .kadicache-operations-<blog_id>.lock files.
  • Automatically cleans up cache files and early routing maps whenever a subsite is archived, marked spam, or deleted (NetworkSiteRetirement.php).

Why Standard WordPress Cache Plugins Struggle on Multisite Networks#

Running WordPress Multisite—whether for a university with 80 department subdirectories, an international brand with 12 regional country subdomains, or a WooCommerce agency hosting multi-brand storefronts—exposes subtle architectural flaws in single-site caching plugins:

  1. Subdirectory vs Root Blog Route Collisions: On a subdirectory network (example.com/ = Blog 1, example.com/fr/ = Blog 2), an advanced-cache.php drop-in that hashes $_SERVER['REQUEST_URI'] without resolving the owning blog_id first risks serving Blog 1’s 404 or cached paths over Blog 2, or wiping all 80 subsites whenever one subsite updates a menu.
  2. switch_to_blog() Plugin Context Corruption: In WordPress core, calling switch_to_blog($blogId) swaps database table prefixes (wp_2_options) and user roles, but it does NOT load or unload the active plugins or theme functions.php of Blog 2! When a naive Network Admin dashboard calls switch_to_blog() and runs cache warmup or optimization hooks inline, Blog 1’s plugins execute against Blog 2’s database—corrupting rewrite rules, WooCommerce tax settings, and custom post types.
  3. Network-Wide Object Cache Stampedes: Flushing Redis FLUSHDB when Blog 14 updates a setting wipes cached objects for all 79 sibling sites simultaneously.

KadiCache solves all three challenges cleanly in Free Core through NetworkEarlyCache.php, NetworkEarlyMap.php, NetworkLifecycle.php, NetworkWorkspace.php, and subsite-scoped Object Cache epochs.

How NetworkEarlyMap & NetworkEarlyCache Route Requests Before WordPress Loads#

When KadiCache is Network Activated inside Network Admin -> Plugins, NetworkLifecycle.php coordinates a deterministic two-level early routing architecture:

Multisite TopologyExample URLsHow NetworkEarlyMap.php Resolves the SubsiteFallback If Map Is Updating
Subdomain Networkus.brand.com, uk.brand.comMatches normalized HTTP Host directly to owning blog_id snapshotYields cleanly to standard WordPress boot
Subdirectory Networkbrand.com/, brand.com/de/shop/Longest-prefix path segment match resolves /de/ -> Blog 2 vs / -> Blog 1Yields cleanly to standard WordPress boot
Custom Mapped Domainsbrand.de, brand.co.ukMaps custom primary & alias domains per blog_id with HTTPS scheme checksYields cleanly to standard WordPress boot

Once NetworkEarlyMap resolves the exact (network_id, blog_id) pair in microseconds, NetworkEarlyCache delegates to that specific subsite’s isolated early-config.php snapshot and cache storage directory. Every subsite maintains its own:

  • Independent Cache Lifetime, Exclusions & Front-End Settings: Blog 2 (a WooCommerce store) can run Delay JS + 10h TTL while Blog 3 (a documentation portal) runs Defer JS + 7d TTL.
  • Independent Preload & Cleanup Queues: Background sitemap warmup and database cleanup run in bounded per-blog batches so one large store never starves smaller blogs.
  • Automatic Retirement Cleanup (NetworkSiteRetirement.php): Archiving, spamming, deactivating, or deleting a subsite in Network Admin -> Sites immediately revokes its early routing entry and purges its cached HTML so retired subsites can never serve stale pages.
FIG 01Managing isolated site caches, JSON configuration snapshots, and health metrics cleanlyZoom 2x

Inside NetworkWorkspace.php: Safe Subsite Operations Without switch_to_blog() Bleed#

Open Network Admin -> KadiCache (toplevel_page_kadicache-network) as a Super Admin (manage_network_options) to view network KPIs, inspect per-site statuses, run bulk Purge selected / Purge all sites or Preload selected / Preload all sites, and configure Shared Configuration (such as network-level Cloudflare or PageSpeed API credentials).

Managing Multisite Subsites via WP-CLI (--url=<subsite>)#

Every KadiCache WP-CLI command honors WordPress’s standard --url=<subsite_url> flag—and ObjectCacheCli.php adds --blog=<id> for surgical single-blog object cache flushes:

BASHMultisite Subsite Diagnostics, Purges & Scoped Object Cache Flushes
# 1. Check Early Cache, drop-in & 24h hit stats for a specific subsite
wp kadicache status --url=https://de.example.com --format=json

# 2. Purge or start sitemap preload on one subsite without touching sibling sites
wp kadicache purge --all --url=https://de.example.com
wp kadicache preload start --url=https://de.example.com

# 3. Flush persistent Object Cache ONLY for Blog ID 3 (O(1) blog epoch bump!)
wp kadicache object-cache flush --blog=3

To replicate a golden configuration across 20 new subsites in seconds, open WP Admin -> KadiCache -> Tools -> Transfer & Staging (SettingsTransfer.php) on your reference subsite, export its clean JSON snapshot (secrets are never exported in plaintext), and import it onto target subsites with a side-by-side diff preview—or manage all subsites centrally inside KadiCache Pulse.

Multisite Object Cache & Shared Network Policy Best Practices#

Large WordPress Multisite installations (25 to 500+ subsites) place heavy pressure on wp_sitemeta and wp_<blog_id>_options lookups. Pair Multisite Early Cache with these two network practices:

  • Enable Redis, Relay, or APCu With Per-Blog Flush Isolation: When KadiCache’s 7-Driver Object Cache is active on Multisite, calling ObjectCacheDropinManager::flush($blogId) (or wp kadicache object-cache flush --blog=4) increments only Blog 4’s cache epoch key in O(1) time—never evicting cached queries belonging to the other 499 subsites!
  • Centralize Shared API Credentials in Network Admin: Configure shared network policies (such as a shared Google PageSpeed Insights v5 API key or Cloudflare account integration) inside Network Admin -> KadiCache -> Shared Configuration so subsite editors benefit from one-click PageSpeed audits without viewing raw infrastructure credentials.
  • Stagger Sitemap Warmup Across Huge Networks: KadiCache’s per-site preload queues automatically yield CPU and memory budgets (PreloadWorkerLock.php) so network-wide updates never saturate PHP-FPM pools.

Frequently Asked Operational Questions

Should KadiCache be Network Activated on WordPress Multisite?
Yes. Network Activating KadiCache in Network Admin -> Plugins allows NetworkEarlyCache.php and NetworkEarlyMap.php to coordinate the single wp-content/advanced-cache.php drop-in across all subsites while keeping each subsite’s cache files and settings isolated.
Does purging cache on one subsite clear the cache of other subsites in the network?
No. Page cache directories, Soft Purge generations, and even Object Cache blog epochs (--blog=<id>) are strictly namespaced per blog_id. Only clicking Clear network cache in Network Admin purges all subsites together.
Does KadiCache support both subdomain and subdirectory Multisite installations?
Yes, including hybrid setups with custom mapped top-level domains (such as brand.fr and brand.de) pointing to individual subsites on the same Multisite network.
What happens when a Super Admin archives or deletes a subsite?
NetworkSiteRetirement.php hooks WordPress site lifecycle transitions automatically, removing the subsite from NetworkEarlyMap and deleting its cached snapshots so archived or deleted sites stop serving cached pages immediately.
Can individual site administrators still clear cache on their own subsite?
Yes. Subsite administrators with manage_options on their site can purge their own subsite’s cache and adjust site-level optimizations, while network-wide drop-in and shared infrastructure policies remain governed by Super Admins (manage_network_options).
Gergis — Lead Systems & Cache Architect
Principal WordPress & Cloud Edge Architect
E-E-A-T Source Verified

Creator of KadiCache’s Early PHP Drop-In, 7-Driver Object Cache Engine, Cloud Remove Unused CSS, and Zero-CLS Lazy Render pipeline.

apps/wordpress-plugin/src/Bootstrap/NetworkEarlyCache.phpapps/wordpress-plugin/src/Cache/Delivery/NetworkEarlyMap.phpapps/wordpress-plugin/src/Admin/NetworkWorkspace.phpapps/wordpress-plugin/src/Bootstrap/NetworkSiteRetirement.php
Was this engineering guide helpful?