Cache Rules Cloudflare – Super Cache Champion for WordPress

⚡ How to Use Cloudflare Cache Rules for WordPress

Cloudflare’s Cache Rules allow you to control how and when your site’s content is cached at the edge — improving speed and reducing load on your server.

WordPress is a dynamic platform, so caching must be configured carefully to avoid issues like caching the admin panel, cart pages, or user-specific content.


📌 What You’ll Learn

  • What Cloudflare Cache Rules are

  • Which pages to cache vs. bypass

  • How to set up smart rules for WordPress

  • How to test and fine-tune your configuration


🧰 What You Need

  • A WordPress site

  • Cloudflare account (free is okay!)

  • Your domain connected to Cloudflare

  • Basic familiarity with WordPress and the Cloudflare dashboard


🔍 Step 1: Understand What to Cache

✅ Good Candidates for Caching:

These pages are the same for all users and don’t change often.

  • Homepage (/)

  • Blog posts (/blog/*)

  • Categories (/category/*)

  • Tags (/tag/*)

  • Static pages (/about, /contact)

❌ Pages You Should Bypass:

These are dynamic and often user-specific — caching them can break things.

  • /wp-login.php (WordPress login)

  • /wp-admin/* (Admin dashboard)

  • /cart, /checkout, /my-account (WooCommerce)

  • Search URLs like ?s=query


🔧 Step 2: Create Cloudflare Cache Rules

Cloudflare’s new Cache Rules (introduced in 2022+) replace and improve upon the old “Page Rules.”

🔹 Access Cache Rules:

  1. Go to your Cloudflare dashboard

  2. Select your site

  3. Navigate to Rules > Cache Rules

  4. Click Create Rule


✅ Rule #1: Cache Public Content

Rule Name: Cache Static Pages
When incoming requests match:

  • Field: URL path

  • Operator: matches

  • Value: / (or /blog/*, /category/*, etc.)

Then apply:

  • Cache Level: Cache Everything

  • Edge TTL: 1 day (or longer)

  • Origin Cache-Control: Respect or Override (based on needs)

Repeat this rule for multiple static paths if needed.


❌ Rule #2: Bypass Admin and Login

Rule Name: Bypass Admin Pages
When incoming requests match:

  • URL path matches /wp-admin/*

  • OR URL path is /wp-login.php

Then apply:

  • Cache Level: Bypass

💡 Tip: Add a second rule for logged-in users if needed using cookies (paid plans only).


❌ Rule #3: Bypass Dynamic Content

Rule Name: Bypass Search and Checkout
When incoming requests match:

  • URI query contains s=

  • OR URL path matches /cart*

  • OR URL path matches /checkout*

  • OR URL path matches /my-account*

Then apply:

  • Cache Level: Bypass


🧪 Step 3: Test Your Setup

How to check if a page is being cached:

  1. Open a private/incognito window

  2. Visit a public page (e.g., homepage)

  3. Right-click > Inspect > Network > Reload

  4. Click the document request and look for:

cf-cache-status: HIT
  • HIT: Page is cached correctly

  • MISS: Page wasn’t cached (yet)

  • DYNAMIC: Page was skipped intentionally (good for admin/cart pages)


🛠 Optional Tools for WordPress

To make cache management easier:

🔹 Official Cloudflare Plugin

  • Purge cache when content updates

  • Set recommended performance/security settings

  • Add WordPress-specific rules easily

🔹 WP Cloudflare Super Page Cache

  • Full page caching with smart purge logic

  • Works well with WooCommerce and logged-in users

  • Gives you more control without coding


🧼 Step 4: Managing Cache

You can clear cache manually if needed:

  • Go to Cloudflare > Caching > Configuration

  • Click Purge Everything (or choose URLs)

Pro Tip: Set WordPress to automatically purge Cloudflare cache when posts are updated using a plugin.


✅ Recap: Sample Cache Rule Table

 

URL Path or QueryActionDescription
/, /blog/*Cache EverythingPublic content
/wp-login.phpBypassLogin page
/wp-admin/*BypassAdmin area
?s=BypassWordPress search results
/cart, /checkoutBypassWooCommerce dynamic pages

🚀 Final Tips

  • Don’t cache pages that change based on user state (e.g., cart, login)

  • Use plugins to automate cache purging

  • Combine with browser cache settings for faster delivery

  • Paid Cloudflare plans offer cookie-based bypass, cache by device type, and custom cache keys if needed

Leave a Comment