Cloudflare Cache Rules for WordPress (Free Plan): My Tested Rule
Out of the box, Cloudflare does not cache your WordPress pages. It caches images, CSS and JavaScript, but every HTML page still comes from your server, and the response says cf-cache-status: DYNAMIC. One Cloudflare cache rule changes that on the Free plan: match your pages, skip the admin, logged-in visitors, search and previews, and mark the rest Eligible for cache.
I tested Cloudflare cache rules for WordPress on a test site: one rule, measured from my PC with curl. The homepage went from DYNAMIC to HIT, and the median time to first byte (TTFB) dropped from 0.645 s to 0.269 s. The admin, a logged-in cookie, search and a preview link all stayed uncached. Below is the exact rule, the numbers, and the one thing a plain rule does not do for you: clearing the cache when you update a post.
Tested by Dolon Bepari, 20 and 21 November 2026
- Server: a throwaway Ubuntu 22.04 VPS (1 vCPU, about 2 GB RAM), aaPanel 7, Nginx 1.30.7, PHP 8.4, WordPress, with the server’s own page cache switched off
- Cloudflare: Free plan, orange cloud (proxied), test domain filecafe.site, one cache rule
- How I measured: curl from my PC in Dhaka, Bangladesh, through Cloudflare; five runs before the rule and five after
- There are no affiliate links in this guide. How I test: how we review
The rule in short (Caching, Cache Rules, Create rule)
- If incoming requests match: Custom filter expression, the expression below (change the hostname)
- Cache eligibility: Eligible for cache
- Edge TTL (how long Cloudflare keeps the page): Ignore cache-control header and use this TTL, 2 hours
- Browser TTL (how long the visitor’s browser keeps it): Respect origin TTL
- Then: turn on automatic purging (for example the official Cloudflare plugin), or purge by hand after every update, so changed posts show up (see the purging section)
(http.host eq "example.com" and not starts_with(http.request.uri.path, "/wp-admin") and not starts_with(http.request.uri.path, "/wp-json") and not ends_with(http.request.uri.path, ".php") and not http.request.uri.path contains "/feed" and not http.cookie contains "wordpress_logged_in" and not http.cookie contains "wp-postpass" and not http.cookie contains "comment_author" and not any(http.request.uri.args.names[*] == "s") and not any(http.request.uri.args.names[*] == "preview"))
Table of Contents
Why Cloudflare does not cache WordPress HTML pages by default
Cloudflare caches files by extension. Images, CSS, JavaScript and fonts are on its default list; HTML is not, because a page can be different for each visitor (logged in, a cart, a comment form with your name). So without a rule, every page request goes through Cloudflare to your server, and Cloudflare marks it DYNAMIC.
This is what my test site’s homepage returned before I added the rule:

If you want to know what each cf-cache-status value means and who decided it, my cf-cache-status explained guide covers all of them. Here we only need two: DYNAMIC (not cached) and HIT (served from Cloudflare’s cache).
Cloudflare Cache Rules vs Page Rules (Cache Everything)
Many WordPress guides still tell you to create a Page Rule with Cache Level: Cache Everything. Cache Rules are the newer way to do the same job. Cloudflare’s Page Rules migration guide (last updated 30 October 2026, checked 21 November 2026) maps Cache Everything to a cache rule with Eligible for cache, and says Page Rules will be replaced by the newer rules.
| Page Rule (old way) | Cache Rule (what I used) | |
|---|---|---|
| Cache the HTML | Cache Level: Cache Everything | Cache eligibility: Eligible for cache |
| Match | A URL pattern with wildcards | An expression: path, cookie, query string, host |
| Skip logged-in visitors by cookie | Older Page Rules guides say this needs the Business plan | Worked on the Free plan in my test (cookie condition in the expression) |
| Rules on the Free plan | A small number | 10 cache rules (Cloudflare’s Cache Rules docs) |
The cookie row is the important one for WordPress. If you cannot skip logged-in visitors, Cloudflare can store a page with your admin bar on it and show it to everyone. With a cache rule, that condition sits right in the expression, and it is free.
Step by step: create the cache rule
No command is needed for this part. In the Cloudflare dashboard:
- Open your domain, then Caching, Cache Rules, and click Create rule. Give it a name you will recognise, such as “WordPress HTML cache”.
- Under If incoming requests match, choose Custom filter expression, click Edit expression, and paste the expression from the next section with your own hostname.
- Under Cache eligibility, choose Eligible for cache.
- Add Edge TTL, choose Ignore cache-control header and use this TTL, and set 2 hours.
- Add Browser TTL and keep Respect origin TTL.
- Click Deploy, then check that the rule shows as Active in the list.


The expression, line by line
This is the expression I tested, with the hostname changed to example.com. It is the same as the one-line version in the box at the top; if the editor does not accept the line breaks, paste that one.
(http.host eq "example.com"
and not starts_with(http.request.uri.path, "/wp-admin")
and not starts_with(http.request.uri.path, "/wp-json")
and not ends_with(http.request.uri.path, ".php")
and not http.request.uri.path contains "/feed"
and not http.cookie contains "wordpress_logged_in"
and not http.cookie contains "wp-postpass"
and not http.cookie contains "comment_author"
and not any(http.request.uri.args.names[*] == "s")
and not any(http.request.uri.args.names[*] == "preview"))
| Line | What it keeps out of the cache | Why |
|---|---|---|
http.host eq "example.com" | Other hostnames (subdomains) on the same Cloudflare domain | The rule only touches the WordPress site |
/wp-admin | The dashboard and admin-ajax.php | Admin pages are per user |
/wp-json | The REST API | Answers change with the request and the user |
ends_with(... ".php") | wp-login.php, wp-cron.php, xmlrpc.php and any other .php file | Login, cron and form handlers must reach the server |
/feed | RSS feeds (and any path containing /feed, such as /feedback/) | So feed readers get new posts quickly; the extra matches are just left uncached |
wordpress_logged_in | Anyone logged in | Stops your admin bar from being cached and shown to visitors |
wp-postpass | Visitors who unlocked a password-protected post | The unlocked post must not be cached for everyone |
comment_author | Visitors who left a comment | WordPress fills the comment form with their name |
"s" | Search results (?s=) | Endless unique URLs that are rarely reused |
"preview" | Post previews (?preview=true) | Drafts must never be cached |
I tested four of these lines directly (the table further down). The others are in the same rule and the same style, but I did not send a separate request for each one.
Why “ignore cache-control” and why 2 hours
Edge TTL has three choices. Two of them follow the Cache-Control header your server sends. My WordPress homepage sent no Cache-Control header at all (see the first screenshot), so “use cache-control header if present, bypass cache if not” would have cached nothing. “Ignore cache-control header and use this TTL” gives a clear result: every matching page stays cached for the time you set.
That choice has a catch. It also ignores headers that say “do not cache”. My /wp-admin/ response carried Cache-Control: no-cache, must-revalidate, max-age=0, no-store, private, and only the expression keeps such pages out. So do not trim the exclusions to make the rule shorter.
Why 2 hours: Cloudflare’s Edge and Browser Cache TTL page (last updated 14 August 2026, checked 21 November 2026) lists the minimum Edge Cache TTL as 2 hours on the Free plan, 1 hour on Pro, and 1 second on Business and Enterprise. Two hours is the shortest a Free plan site allows, which limits how long an old version of a page can stay cached if a purge is missed.
My results: DYNAMIC to HIT, and TTFB before and after
After deploying the rule and waiting about a minute, I requested the homepage three times and looked at the headers.
▶ On your own computer, in Windows cmd (not PowerShell). On Mac or Linux, use curl instead of curl.exe and /dev/null instead of NUL:
curl.exe -s -o NUL -D - https://example.com/
What it does: requests your homepage through Cloudflare, throws the page away and prints only the response headers. It changes nothing. Look for the cf-cache-status line. The first request after a purge is usually MISS; the next ones should say HIT.
My first response is cut off in the screenshot; the two after it both said cf-cache-status: HIT. The Age header (how many seconds the copy had been in Cloudflare’s cache) was 0 on one and 31 on the other, in the same second, which suggests two different stored copies. Either way, my server did not build those pages.

Then I measured time to first byte, five times before the rule and five times after, with the same command from the same PC.
▶ On your own computer, in Windows cmd (not PowerShell). On Mac or Linux, use curl instead of curl.exe and /dev/null instead of NUL:
curl.exe -o NUL -s -w "%{time_appconnect} %{time_starttransfer}\n" https://example.com/
What it does: requests the homepage and prints two times in seconds: when the secure connection was ready (time_appconnect) and when the first byte of the page arrived (time_starttransfer, the TTFB). It changes nothing. Run it five times and use the middle value, not the average.


| Run | Before the rule (TTFB) | After the rule (TTFB) |
|---|---|---|
| 1 | 0.647800 s | 0.268887 s |
| 2 | 0.553074 s | 1.362193 s |
| 3 | 0.663297 s | 0.254841 s |
| 4 | 0.507980 s | 0.650059 s |
| 5 | 0.645407 s | 0.243569 s |
| Median | 0.645 s | 0.269 s |
The median TTFB fell from 0.645 s to 0.269 s (0.65 → 0.27 s rounded), about 58% lower. The secure connection was ready at 0.12 to 0.15 s in both sets, so the saving came after the connection, most likely because Cloudflare answered from its cache instead of waiting for WordPress to build the page.
Two of the five runs after the rule were slow, 1.362 s and 0.650 s. My command did not print headers, so I cannot tell whether those two were cache misses or something else. That is why I use the median. If you test your own site, run it several times and expect an odd slow result now and then.
Your numbers will differ. My test server was small; a fast server close to your visitors gains less, a slow or distant one gains more. My guide to reducing TTFB in WordPress shows how page cache and edge cache add up on the same server.

Bypass test: what the rule did not cache
A cache rule is only safe if it leaves the right pages alone. I sent four requests that must never come from the cache.
▶ On your own computer, in Windows cmd (not PowerShell). On Mac or Linux, use curl instead of curl.exe and /dev/null instead of NUL:
curl.exe -s -o NUL -D - https://example.com/wp-admin/
curl.exe -s -o NUL -D - -H "Cookie: wordpress_logged_in_test=1" https://example.com/
curl.exe -s -o NUL -D - "https://example.com/?s=test"
curl.exe -s -o NUL -D - "https://example.com/?p=1&preview=true"
What it does: four header-only requests, one at a time: the admin, the homepage with a fake logged-in cookie, a search, and a preview link. None of them logs you in or changes anything. Every one should say DYNAMIC, never HIT. (I used the cookie name wordpress_logged_in_lab; any name that starts with wordpress_logged_in matches.)
| Request | Status | cf-cache-status |
|---|---|---|
/wp-admin/ | 302 to the login page | DYNAMIC |
Homepage with a wordpress_logged_in cookie | 200 | DYNAMIC |
/?s=test (search) | 200 | DYNAMIC |
/?p=1&preview=true (preview, logged out) | 301 to /?p=1 | DYNAMIC |


The same homepage without the cookie was a HIT about a minute earlier, so the cookie line is what kept it out. I did not test the comment, password-protected post or feed lines with separate requests.
Purging: who clears the cache when you update a post
This is the part most guides to Cloudflare cache rules for WordPress skip. With my rule, Cloudflare keeps each page for 2 hours. If you fix a typo or publish a post, visitors can see the old homepage or the old post until that copy expires, unless something purges it.
You have four ways to handle it:
- Purge by hand. In Cloudflare, open Caching, Configuration, and use Purge Cache (a single URL, or Purge Everything). A fallback for a site you rarely update; if you forget, visitors see the old page for up to 2 hours. At the end of my lab I used Purge Everything after deleting the rule.
- Cloudflare’s official WordPress plugin. Its docs say the Automatic Cache Management feature purges the related URLs when you add, edit or delete a post, page, attachment or comment (Cloudflare docs, checked 21 November 2026). I did not test it with this rule.
- A cache plugin that creates its own Cloudflare rules and purges them. FlyingPress and Super Page Cache both do this. In that case do not add my rule as well; let the plugin manage it. My FlyingPress review and Super Page Cache review show how each one sets up Cloudflare and what it did to TTFB on my test server.
- Cloudflare APO. Cloudflare’s paid WordPress add-on (about $5 a month on the Free plan), which caches pages and purges on updates through the official plugin. I have not tested APO.
If you use WP Rocket, my WP Rocket review explains that its Cloudflare add-on only clears Cloudflare’s cache; to cache pages at the edge you need APO or your own rule. A rule like mine, with that add-on doing the clearing, is one way to pair them; I have not tested that pair. And if you only want to empty your caches after a change, my guide to clearing WordPress cache covers every layer, Cloudflare included.
What can break with a WordPress cache rule
I did not see any of these problems in my test, because the rule excluded the cases below. They are the usual reasons a cache rule goes wrong, so check them on your own site.
| Problem | Cause | Fix |
|---|---|---|
| Visitors see your admin bar | Logged-in cookie not excluded | Keep the wordpress_logged_in line |
| Updated post still shows the old version | No purge after the update | Purge, or use a plugin that purges (section above) |
| Cart or checkout shows someone else’s items (WooCommerce) | Shop pages and cart cookies not excluded | My rule has no WooCommerce lines and I did not test a shop; add the cart and checkout paths and the WooCommerce cookies before you use it on a store |
| Comment form shows another visitor’s name | Comment cookie not excluded | Keep the comment_author line |
| Login loop or failed form submits | .php handlers cached | Keep the .php line |
| Pages never turn HIT | Development Mode on, another cache rule set to Bypass cache placed after this one, or you are testing while logged in | Test logged out with curl; see how to check if WordPress cache is working |
For the rest of the Cloudflare setup (SSL mode, security, what to leave alone) see my Cloudflare settings for WordPress guide. It uses the FlyingPress integration instead of a hand-made rule, which is the other path described above.
Cache rule, plugin integration or APO: which to use
| Option | Cost | Who purges | Best for |
|---|---|---|---|
| Your own cache rule (this guide) | Free | You, or the official Cloudflare plugin | Small sites, any cache plugin, people who like control |
| Cache plugin’s Cloudflare integration (FlyingPress, Super Page Cache) | Plugin price (Super Page Cache has a free version) | The plugin | Sites that update often and want it automatic |
| Cloudflare APO | Paid add-on on the Free plan | The official plugin | Sites that want Cloudflare’s own WordPress product |
If you publish often, a plugin integration saves you from purging by hand. On a site that changes rarely, the free rule in this guide plus automatic purging from the official Cloudflare plugin is enough; purging by hand also works, as long as you remember to do it after every change.
Cloudflare cache rules for WordPress: FAQ
Does Cloudflare cache WordPress pages by default?
No. Cloudflare caches static files such as images, CSS and JavaScript by default, but not HTML. A WordPress page shows cf-cache-status DYNAMIC until you add a cache rule, a plugin integration or APO.
Can I bypass the Cloudflare cache for logged-in users on the Free plan?
Yes, with a cache rule. Put a condition like not http.cookie contains wordpress_logged_in in the expression. In my test a request with that cookie stayed DYNAMIC while the same page without it was a HIT.
Do I need Cloudflare APO for WordPress?
No. A free cache rule caches your pages too. APO adds automatic purging through the official plugin and costs extra on the Free plan. With a free rule you purge by hand, or let a plugin purge for you.
Are Cloudflare Page Rules going away?
Cloudflare’s migration guide says Page Rules will be replaced by newer rules and maps Cache Everything to a cache rule with Eligible for cache. New setups should use a cache rule.
How long does Cloudflare keep a cached WordPress page?
As long as the Edge TTL in your rule. On the Free plan the shortest Edge TTL is 2 hours, according to Cloudflare’s docs, and that is what I used. A purge removes the page sooner.
Why does my WordPress admin bar show up for visitors on Cloudflare?
A page was cached while you were logged in. Your rule or plugin is not skipping the wordpress_logged_in cookie. Add that exclusion, then purge the Cloudflare cache.
Is a Cloudflare cache rule safe for WooCommerce?
Not as written here. My rule has no WooCommerce exclusions and I did not test a shop. Exclude the cart, checkout and account pages and the WooCommerce cart and session cookies first, or use a plugin built for it.
How do I check if my Cloudflare cache rule works?
Request a page logged out and read the cf-cache-status header. In Windows cmd run curl.exe with -s -o NUL -D – and the page URL. MISS then HIT means the rule works; DYNAMIC means the rule did not match.
