Skip to content
  • Quick Ref
  • Contact
  • About
wpcanyon.com

wpcanyon.com

Cloudflare cache rules for WordPress (no admin caching)

Posted on August 19, 2025 By Admin No Comments on Cloudflare cache rules for WordPress (no admin caching)

Cloudflare Cache Rules for WordPress (No Admin Caching)

If you use Cloudflare with your WordPress site, you might notice issues when the WordPress admin dashboard or login pages get cached. This can cause outdated content, login problems, or broken admin functionality. The quick fix is to set up Cloudflare cache rules that exclude the WordPress admin area and login pages from caching, ensuring smooth backend operations while still benefiting from caching on the public site.

Quick Fix

  1. Log in to your Cloudflare dashboard.
  2. Navigate to the “Rules” section and select “Page Rules” or “Cache Rules” (depending on your Cloudflare plan).
  3. Create rules to bypass cache for URLs related to WordPress admin and login:
    • example.com/wp-admin/*
    • example.com/wp-login.php*
  4. Set these rules to Bypass Cache or Cache Level: Bypass.
  5. Save and deploy the rules.
  6. Test by logging in and accessing the admin dashboard to confirm no caching issues.

Why This Happens

Cloudflare caches static content by default to speed up your website. However, WordPress admin pages and login screens are dynamic and personalized. If Cloudflare caches these pages, users may see stale content or be unable to log in properly. This happens because Cloudflare does not differentiate between public and admin URLs unless explicitly told to do so. Therefore, you need to create cache rules that exclude admin and login URLs from caching.

Requirements

  • A Cloudflare account with your WordPress site added.
  • Access to the Cloudflare dashboard to create cache or page rules.
  • Basic understanding of WordPress URL structure.

Step-by-Step: Setting Up Cloudflare Cache Rules for WordPress Admin

  1. Log in to Cloudflare at https://dash.cloudflare.com.
  2. Select your domain from the list.
  3. Go to the “Rules” tab in the dashboard sidebar.
  4. Create a new Page Rule or Cache Rule (depending on your Cloudflare plan):
    • Click Create Page Rule or Create Cache Rule.
  5. Enter the URL pattern for the WordPress admin area:
  6. https://example.com/wp-admin/*
  7. Set the rule action to: Cache Level: Bypass or Bypass Cache.
  8. Save and deploy the rule.
  9. Create a second rule for the login page:
  10. https://example.com/wp-login.php*
  11. Set the same bypass cache action.
  12. Save and deploy.
  13. Optional: Add rules to bypass caching for REST API and AJAX calls:
  14. https://example.com/wp-json/*
    https://example.com/admin-ajax.php*
  15. Test your site: Log in and navigate the admin dashboard to confirm no caching issues.

Code Snippets for Cloudflare Cache Rules

Here are the exact URL patterns to use when creating your Cloudflare rules:

URL Pattern Cache Action Purpose
https://example.com/wp-admin/* Bypass Cache Exclude WordPress admin pages
https://example.com/wp-login.php* Bypass Cache Exclude login page
https://example.com/wp-json/* Bypass Cache Exclude REST API requests
https://example.com/admin-ajax.php* Bypass Cache Exclude AJAX requests

Note: Replace example.com with your actual domain.

Common Pitfalls

  • Not using HTTPS in URL patterns: Cloudflare rules are protocol-specific. Use https:// if your site uses SSL.
  • Incorrect wildcard usage: Use * to match any characters after the path. For example, /wp-admin/* matches all admin subpages.
  • Rule order matters: Cloudflare processes rules in order. Place bypass rules above any general caching rules.
  • Forgetting REST API and AJAX: These endpoints are critical for admin functionality and should also be excluded from caching.
  • Not clearing Cloudflare cache after changes: Purge cache to ensure new rules take effect immediately.

Works On

  • Cloudflare CDN (all plans with Page Rules or Cache Rules support)
  • WordPress sites on Apache, Nginx, LiteSpeed, or other web servers
  • Hosting control panels like cPanel, Plesk, or custom setups

FAQ

Q: Can I cache the WordPress admin area safely?
A: No, caching the admin area can cause outdated content and login issues. Always bypass cache for admin URLs.
Q: What happens if I don’t exclude wp-login.php from caching?
You may experience login failures or see cached login pages that prevent proper authentication.
Q: Do I need to exclude REST API and AJAX URLs?
Yes, these endpoints are essential for dynamic admin functions and should not be cached.
Q: How do I clear Cloudflare cache after adding rules?
Go to the “Caching” tab in Cloudflare dashboard and click “

Speed & Security Tags:Cache Rules, CDN, Cloudflare, Page Rules

Post navigation

Previous Post: WooCommerce: Add a handling fee or surcharge
Next Post: Disable comments sitewide (and close on old posts)

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Top WordPress Themes for Blogs in 2025
  • WordPress Admin Panel Trick: Adding ID Field to the Posts Listing
  • Solution previous_posts_link and next_posts_link Not Working
  • Show Top Commentators in WordPress Without a Plugin
  • How to Style Admin Comments in WordPress

Recent Comments

    Archives

    • August 2025

    Categories

    • Admin & Blocks
    • Admin & UI
    • Automation
    • Automation & Plugins
    • Comments
    • Comparisons
    • Database & Revisions
    • Developer Snippets
    • Fixes & Errors
    • Media & Thumbnails
    • Queries & Pagination
    • Security
    • Speed & Security
    • Tips & Tricks
    • WooCommerce How‑tos
    • WordPress Snippets
    • WordPress Themes
    • Terms & Conditions
    • Affiliate Disclosure

    Copyright © 2025 wpcanyon.com.

    Powered by PressBook WordPress theme

    Also by the maker of MySurveyReviews.com