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.
- 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_idinto 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>.lockfiles. - 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:
- Subdirectory vs Root Blog Route Collisions: On a subdirectory network (
example.com/= Blog 1,example.com/fr/= Blog 2), anadvanced-cache.phpdrop-in that hashes$_SERVER['REQUEST_URI']without resolving the owningblog_idfirst risks serving Blog 1’s 404 or cached paths over Blog 2, or wiping all 80 subsites whenever one subsite updates a menu. switch_to_blog()Plugin Context Corruption: In WordPress core, callingswitch_to_blog($blogId)swaps database table prefixes (wp_2_options) and user roles, but it does NOT load or unload the active plugins or themefunctions.phpof Blog 2! When a naive Network Admin dashboard callsswitch_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.- Network-Wide Object Cache Stampedes: Flushing Redis
FLUSHDBwhen 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 Topology | Example URLs | How NetworkEarlyMap.php Resolves the Subsite | Fallback If Map Is Updating |
|---|---|---|---|
| Subdomain Network | us.brand.com, uk.brand.com | Matches normalized HTTP Host directly to owning blog_id snapshot | Yields cleanly to standard WordPress boot |
| Subdirectory Network | brand.com/, brand.com/de/shop/ | Longest-prefix path segment match resolves /de/ -> Blog 2 vs / -> Blog 1 | Yields cleanly to standard WordPress boot |
| Custom Mapped Domains | brand.de, brand.co.uk | Maps custom primary & alias domains per blog_id with HTTPS scheme checks | Yields 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 inNetwork Admin -> Sitesimmediately revokes its early routing entry and purges its cached HTML so retired subsites can never serve stale pages.
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:
# 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=3To 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)(orwp kadicache object-cache flush --blog=4) increments only Blog 4’s cache epoch key inO(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 Configurationso 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?
Does purging cache on one subsite clear the cache of other subsites in the network?
Does KadiCache support both subdomain and subdirectory Multisite installations?
What happens when a Super Admin archives or deletes a subsite?
Can individual site administrators still clear cache on their own subsite?
Creator of KadiCache’s Early PHP Drop-In, 7-Driver Object Cache Engine, Cloud Remove Unused CSS, and Zero-CLS Lazy Render pipeline.