Skip to main content
KadiCache
Browse 37 Docs Guides & Search

Cloudflare OAuth 2.0, APO & 5-Tab Edge Command Center Guide

Connect Cloudflare via 1-click OAuth 2.0 PKCE or scoped API tokens, govern all 5 Edge Command Center tabs, sync APO & Edge HTML rules, and prevent Rocket Loader conflicts.

Integrations/Cdn/Cloudflare/CloudflareOAuth.phpIntegrations/Cdn/Cloudflare/CloudflareZoneControl.phpIntegrations/Cdn/Cloudflare/CloudflareEdgeRules.phpIntegrations/Cdn/CloudflarePurge.php
WP Admin -> KadiCache -> Cloudflare (OAuth 2.0 & API Token)
MODULE 31 · 2X RETINA
Connect Cloudflare via Zero-Knowledge OAuth 2.0 (PKCE S256) or a scoped API token encrypted at rest.2880×1840 WebP
Quick Summary · 30-Second Operational SpecSource-Verified Guide
WP Admin Path
WP Admin -> KadiCache -> Cloudflare (5-Tab Edge Command Center)
Expected Outcome
300+ Global Edge PoPs · 30-URL Batched Purges · 1-Click OAuth 2.0 PKCE
Key Marker / Engine
CF-Cache-Status: HIT | CloudflareOAuth.php | CloudflareZoneControl.php
  • Connects via 1-Click Zero-Knowledge OAuth 2.0 (PKCE S256) or a Scoped API Token (Zone:Read, Zone Settings:Edit, Cache Purge:Purge, Analytics:Read)—never asking for your Global API Key (CloudflareOAuth.php).
  • Provides a 5-Tab Edge Command Center inside WordPress (Overview & Purge, Edge Caching & APO, Speed & Network, Security & AI Bots, SSL/TLS & Connection) in 100% Free Core.
  • Batches edge purges into 30-URL chunks (CloudflarePurge.php + CloudflareQueueMerger.php) with automatic HTTP 429 Retry-After Action Scheduler backoff and official Cloudflare APO ownership coexistence.
  • Detects and disables conflicting Cloudflare Rocket Loader & Auto Minify toggles in one click so Defer & Safe Delay JS never double-rewrites scripts.

Why Connecting Cloudflare Directly to KadiCache Transforms Global TTFB#

Even when your origin server responds in 14 ms via Early PHP Delivery, physics imposes speed-of-light latency across oceans: a shopper in Sydney or Tokyo connecting to a WordPress VPS in Frankfurt still pays 220 – 310 ms of transcontinental TCP/TLS round-trip time.

Routing your domain through Cloudflare’s 300+ global edge PoPs—and synchronizing cache invalidations, Edge HTML Cache Rules, or Automatic Platform Optimization (APO) inside KadiCache’s 5-Tab Cloudflare Edge Command Center—serves cached HTML and static assets from 15 – 35 ms away anywhere on Earth while guaranteeing edits publish immediately.

FIG 01Connecting Cloudflare via Zero-Knowledge OAuth 2.0 PKCE S256 or a scoped API token inside WP Admin -> KadiCache -> CloudflareZoom 2x

Two Secure Ways to Connect (CloudflareOAuth.php)#

Legacy WordPress plugins used to ask for your Cloudflare Global API Key + account email—giving one WordPress database full root access to every domain in your Cloudflare account! KadiCache refuses Global API Keys by design and offers two least-privilege authentication flows:

  1. 1-Click Cloudflare OAuth 2.0 (PKCE S256): Click Connect with Cloudflare, select the single domain zone you want to authorize in Cloudflare’s official consent screen, and KadiCache encrypts the resulting token at rest via Libsodium.
  2. Scoped API Token (wp-config.php or Admin UI): Click Create Scoped Token Template to open Cloudflare’s token builder pre-populated with minimum permissions (Zone:Read, Zone Settings:Edit, Cache Rules:Edit, Cache Purge:Purge, Analytics:Read) restricted strictly to your single zone.

On WordPress Multisite networks (Multisite Network Guide), Super Admins can also share a network-level Cloudflare credential across subdomain or mapped-domain subsites (CloudflarePurge::usingNetworkCredentials()).

FIG 02Viewing 24h/7d/30d GraphQL Edge Analytics, Quick Development Mode, and targeted URL/zone purge controlsZoom 2x

Complete Tour of All 5 Cloudflare Edge Command Center Sub-Tabs#

Sub-Tab in WP Admin -> KadiCache -> CloudflareKey Controls & Telemetry (CloudflareZoneControl.php)Recommended Production Configuration
1. Overview & PurgeLive 24h / 7d / 30d GraphQL requests, bandwidth & edge hit ratio (CloudflareAnalytics.php), Development Mode (3h auto-off), Apply Recommended Preset, and targeted URL / Full Zone PurgeUse Apply Recommended Preset on day one; reserve Purge Entire Cloudflare Zone for major theme redesigns
2. Edge Caching & APOFree Edge HTML Cache Rule (CloudflareEdgeRules.php), Cloudflare APO toggle + Cache by Device Type, Browser Cache TTL (Respect Existing Headers), and s-maxage edge TTLEnable Respect Existing Headers + either Edge HTML Cache Rule (Free Cloudflare plans!) or APO (if subscribed) while bypassing wp-*, /cart/, /checkout/, and WooCommerce cookies
3. Speed & NetworkBrotli compression, Early Hints (HTTP 103), Speed Brain speculative prefetch, HTTP/3 (QUIC), 0-RTT, and Rocket Loader conflict guardTurn ON Brotli, Early Hints, HTTP/3, and Speed Brain; keep Rocket Loader OFF!
4. Security & AI BotsWordPress WAF Shield Rule, AI Bots Protection (ai_bots_protection), Bot Fight Mode, Browser Integrity Check, and Security LevelEnable WordPress WAF Shield to block /xmlrpc.php & /wp-login.php brute-force floods at the edge before PHP runs
5. SSL/TLS & ConnectionSSL mode check (Full (Strict) recommended), Always Use HTTPS, Minimum TLS 1.2, TLS 1.3, and OAuth / Token disconnectAlways run Full (Strict) with a valid origin TLS certificate to avoid redirect loops
FIG 03Synchronizing Cloudflare APO and Free Edge HTML Cache Rules with WordPress cookie bypass safeguardsZoom 2x

Batched 30-URL Purges, 429 Retry-After Queue & Official APO Coexistence#

Cloudflare’s REST v4 Purge-by-URL API enforces strict per-call URL limits (30 URLs per request) and rate quotas. CloudflarePurge.php and CloudflareQueueMerger.php handle edge invalidation cleanly:

  • Automatic Deduplication & 30-URL Chunking: Updating a WooCommerce product purges the product URL, its parent categories, shop archive, and linked translations in deduplicated 30-URL batches (cloudflare_purge_http optionally purges http:// alongside https://).
  • Resilient 429 Retry-After Backoff: If bulk imports trigger Cloudflare rate limiting, remaining URLs spill cleanly into an Action Scheduler retry queue honoring Cloudflare’s exact Retry-After header—zero lost invalidations and zero stalled admin saves!
  • Official Cloudflare APO Plugin Coexistence: When the official Cloudflare WordPress plugin is active with APO auto-purge enabled, KadiCache detects it automatically—preventing duplicate purge loops while still forwarding explicit KadiCache API/CLI purges.

Why Cloudflare Rocket Loader Must Stay OFF#

Cloudflare’s legacy Rocket Loader rewrites <script> tags at the CDN edge into asynchronous type="text/rocketscript" blobs without knowing WordPress script handle dependencies (jQuery, wp-i18n, Elementor, or WooCommerce checkout). Running Rocket Loader alongside KadiCache’s Defer or Delay JavaScript double-wraps scripts and breaks mobile menus! KadiCache flags an active Rocket Loader toggle immediately inside Speed & Network (and Tools) so you can turn it OFF in one click.

Frequently Asked Operational Questions

Can I use the Free Edge HTML Cache Rule on a $0/month Free Cloudflare account?
Yes! CloudflareEdgeRules.php deploys a modern Cloudflare Cache Rule on standard Free Cloudflare zones—bypassing wp-admin, logged-in cookies, and WooCommerce cart/session cookies while caching guest HTML at the edge.
Does KadiCache require my Cloudflare Global API Key?
Never. KadiCache supports 1-click OAuth 2.0 (PKCE S256) and least-privilege Scoped API Tokens restricted to your single domain zone.
Should I enable Cloudflare Auto Minify alongside KadiCache CSS & JS Minification?
No—and Cloudflare has deprecated Auto Minify in favor of origin optimization plus Brotli compression. Let KadiCache handle CSS/JS optimization on origin and enable Brotli in Cloudflare -> Speed & Network.
Does purging a single URL in KadiCache wipe my entire Cloudflare zone cache?
No! Unless you explicitly enable cloudflare_purge_everything or click Purge Entire Zone, KadiCache invalidates only the exact modified URLs in 30-URL batches so the rest of your global edge cache stays warm.
Can subsite admins on WordPress Multisite accidentally purge the entire shared Cloudflare zone?
No. CloudflareZoneControl enforces strict Multisite governance—full-zone mutations and zone-wide purges require Network Administrator privileges.
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/Integrations/Cdn/Cloudflare/CloudflareOAuth.phpapps/wordpress-plugin/src/Integrations/Cdn/Cloudflare/CloudflareZoneControl.phpapps/wordpress-plugin/src/Integrations/Cdn/Cloudflare/CloudflareEdgeRules.phpapps/wordpress-plugin/src/Integrations/Cdn/CloudflarePurge.php
Was this engineering guide helpful?