• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
NameHero® Blog

NameHero® Blog

Web Hosting Tips & Resources From NameHero

  • AI Agents
    • OpenClaw
    • Claude Code
    • n8n
    • Hermes Agent
    • Open WebUI
    • Docker
  • Hosting
    • Web Hosting
    • WordPress Hosting
    • WooCommerce Hosting
    • Enterprise Hosting
    • Email Hosting
    • HeroicGuard
    • GPU Hosting
    • Website Builder
  • VPS
    • Managed VPS
    • Unmanaged VPS
    • Flex VPS
  • Reseller
  • Gaming
  • Domains
  • Account
  • Blog Home
  • Categories
  • Authors

Use Cloudflare Cache Rules Instead Of Page Rules

Bhagwad Park

Published on: November 7, 2022

Categories: Website Performance 1

These days, Cloudflare is putting a lot of effort into revamping its cache system. The other day, I wrote about the new Cloudflare Cache Reserve system that had infinite retention using R2 storage.  Now Cloudflare is splitting its well-known “Page Rules” system into different streams, with one stream dedicated solely to caching. Here’s how it works.

Using Cache Rules Instead of Page Cache

In your Cloudflare settings dashboard, go to “Caching -> Cache Rules,” as shown here:

Cloudflare Cache Rules Filter
Cloudflare Cache Rules Filter

As you can see, unlike Page Rules, which only allowed you to create rules based on URL patterns, Cache Rules let you filter out a lot more. For example, you can set separate caching rules for certain file formats, filter by the user agent, the referrer, and more. You’re not restricted to using only the options from the dropdown box – you can use any of the expressions allowed in the Cloudflare Fields Reference through the expression editor.

For example, the following filter applies to all PNG images:

any(http.request.headers["content-type"][*] == "image/png")

Of course, you could also filter by the “.png” filename extension. The point of the above example is to demonstrate the range of filters you can use with the Cloudflare Cache Rules. Once all the Page Rules are split into separate streams, I foresee they will vanish entirely. And why not?

Matching with “AND”/”OR” Rules

In addition to having greater control over which URLs get filtered, you can mix and match different conditions using “AND”/”OR” statements. So you can create detailed exceptions for caching. This opens up new avenues for caching. For example, you can create a cache rule for a URL and create an exception if it contains a particular query string. You can even mix this with Page Rule rewrites so that all links you click on a URL containing a certain query string will rewrite to use the same query string.

This kind of fine-grained caching is very cool!

Increased Limits for Free and Pro Tiers

The old Page Rules limit for free accounts was just three rules. With the new Cache Rules, that limit is ten for the free tier and 25 for the Pro tier. Here’s a screenshot of a free domain on Cloudflare with the new quota:

Ten Free Cloudflare Cache Rules
Ten Free Cloudflare Cache Rules

As you can see, this is a massive upgrade from what we had previously. Considering that we’ll get expanded limits for each breakdown, this represents a new level of control over the various aspects of traffic filtering, even for free users.

No Need for “Stale-While-Revalidate” Code

Earlier, I’d written about how to ensure that we serve stale content to users while refreshing content from the origin. This allows Cloudflare to delay serving fresh content just one more time while refreshing its own cache. It ensures that new content will be served as fast as old content.

With Cloudflare Cache rules, we no longer need to worry about fiddling with .htacess files. Instead, you can specify the stale-while-revalidate condition within the Cache Rules interface like this:

Serving State Content While Updating
Serving State Content While Updating

This is much easier than using a .htaccess directive that risks breaking your site. You can see from the screenshot that you can also use a bunch of other directives, such as specifying the EDGE TTL or even configuring the cache keys used to determine whether or not Cloudflare should serve separate cached content for device types and more.

Complete Caching Control

Cloudflare already had an impressive set of caching filters. But with the latest Cache Control feature it takes caching to the next level. Combined with Cache Reserve, it’s almost like having a secondary hosting provider at a fraction of the cost!

Bhagwad Park Profile Picture
Bhagwad Park

I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!

Reader Interactions

Comments

  1. Michael Michael says

    May 23, 2025 at 7:14 am

    Hi, thanks for your details explanation. My question is, what is the the recommended cache rules to use?

    Thanks.

    Reply

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow & Subscribe

Exclusive promos, content and more!


Most Popular Posts

NameHero’s Recommended WordPress Plugin and Theme Setup

WordPress Hosting vs. Web Hosting – What’s The Difference?

How To Increase The InnoDB Buffer Pool Size

How To Fix A Stuck All-in-One WP Migration Import

How To Add A Subdomain In Cloudflare

Top Categories

  • WordPress
  • WordPress Tutorials
  • OpenClaw Hosting
  • Enterprise Hosting
  • WooCommerce
  • Web Hosting
  • Resellers
  • Website Security
  • Website Development
  • Website Performance
  • VPS Hosting
  • SEO Tips
  • Announcements
  • Domain Registration
NameHero

NameHero® proudly provides web hosting to over 40,000 customers with 99.9% uptime to over 750,000 websites.

  • Master Card
  • Visa
  • American Express
  • Discover
  • Paypal
Products
  • Web Hosting
  • Managed VPS Hosting
  • Unmanaged VPS Hosting
  • Flex VPS Hosting
  • WordPress Hosting
  • WooCommerce Hosting
  • Reseller Hosting
  • Enterprise Hosting
  • GPU Hosting
  • Email Hosting
  • HeroicGuard
  • Domains
  • Website Builder
  • AI Agent Hosting
Help & Support
  • NameHero Blog
  • NameHero Gaming Blog
  • Support
  • Help Center
  • Migrations
  • Affiliates
  • Gaming Affiliates
  • Call 1-855-984-6263
Company
  • About Us
  • Contact Sales
  • Reviews
  • Uptime
  • We're Hiring

Copyright © 2026 Name Hero, LLC. All rights reserved.
NameHero® is a registered trademark.

  • Privacy Policy
  • Terms of Use
  • Acceptable Use Policy
  • Payment Policy
  • DMCA