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

NameHero Blog

Web Hosting Tips & Resources From NameHero

  • Web Hosting
  • Reseller Hosting
  • Managed Cloud
  • Domains
  • Account
  • Blog Home
  • Categories

My Favorite Cloudflare Page Rules

Bhagwad Park

Published on: August 5, 2020

Categories: Website Performance 1

Cloudflare can be used in innovative ways to improve the performance of your site. The most obvious use-case is of course, the caching of static assets, but there are so many other functionalities. For example, page rules are some of the most impactful features that Cloudflare offers. We can use them for caching, forwarding, disabling performance on specific sections, and more. In this article, I’ll share some of my favorite Cloudflare page rules that I use on my website WP-Tweaks.com.

Full Site Caching with a Plugin

These page rules aren’t set by you manually, but through a plugin. I’d written earlier about how I managed to achieve TTFB rules of under 0.5 seconds using the WP Cloudflare Super Page Cache plugin. Use this plugin only if you have a mostly static website that doesn’t change a lot, though the plugin also has settings for WooCommerce, so you can still give it a go.

These page rules are set via an API, so you don’t need to make the changes manually.

Forwarding to “www”

A lot of sites explicitly want their visitors to use “www”. So they’ll set up redirect rules in .htaccess rules to enable both www and https. The idea is for a request like this:

example.com

to become

https://www.example.com

I’d written earlier about how to redirect all traffic to the preferred “https://www” version using just one htaccess rule instead of multiple ones. That’s still a good thing to do, but you can save yourself some server load by outsourcing the logic to Cloudflare’s EDGE servers instead. To do this, we have a page rule like this:

Redirect non-www to www URLs Using Cloudflare Page Rules
Redirect non-www to www URLs Using Cloudflare Page Rules

This page rule takes a “non-www” URL and instantly makes a 301 redirect to the “https://www” version as shown above. It’s typically much faster than an .htaccess rule because it’s handled by the closest Cloudflare EDGE server!

Note that we’re not intercepting “http” requests. That’s because there’s already a setting in the Cloudflare section labeled SSL/TLS -> “Edge Certificates” called “Always Use HTTPS” that looks like this:

Cloudflare Setting to Use HTTPS
Cloudflare Setting to Use HTTPS

Enabling this option automatically uses the HTTPS protocol for all your assets – not just your pages, but also your images, CSS and JS files. So this part is already taken care of, and now we just need to deal with the “www” aspect.

Forwarding Affiliate URLs

If you’re running an affiliate site, you can use Cloudflare for blazing fast redirection. For example, I have page rules set up like this:

Forward Affiliate URLs with Cloudflare
Forward Affiliate URLs with Cloudflare

I use the “ThirstyAffiliate” URLs (like so many others), that cloaks my affiliate landing pages. Using Cloudflare rules, we can easily redirect them without needing to rely on your origin server. It works great! Every additional second wasted is a potential lost sale. Let Cloudflare help you avoid that!

Disabling WordPress Admin Areas

I’d written earlier about whether I thought the Cloudflare “Pro” plan was worth it. The WAF is a huge benefit, and it works really well. However, it sometimes blocks legitimate requests from the WordPress admin section, preventing posts from being saved in Gutenberg. To avoid this, we can disable security and performance in the admin section as shown here:

Disabling Security and Performance for WordPress Admin Pages
Disabling Security and Performance for WordPress Admin Pages

This neatly avoids all false positives from occurring when you’re trying to edit your site!

20 Page Rules with Cloudflare Pro

The free version of Cloudflare only gives you 3 page rules to play with. That’s not enough for all the things I want to do on my site. The Cloudflare Pro plan however, allows me a generous quota of 20 page rules, and that gives me a lot of breathing room. I don’t really have to worry about not being able to do everything I want.

But if you’re still on the free plan, you’ll have to pick and choose which ones are important to you. Personally, I would choose full page caching, forwarding your most important affiliate URL, and one more. I hope you find the right balance that works for you!

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. Andrew Burkman says

    February 13, 2021 at 10:05 pm

    i am new to cloudflare and this was helpful figuring out the best page rules. 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 (2023)

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

How To Inline And Defer CSS On WordPress Without Plugins

Top Categories

  • WordPress
  • Website Performance
  • Web Hosting
  • Resellers
  • Website Security
  • VPS Hosting
  • Website Development
  • 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
Name Hero
  • Web Hosting
  • Reseller Hosting
  • Managed Cloud
  • Domains
Help & Support
  • NameHero Blog
  • Knowledgebase
  • Announcements
  • Affiliates
Company
  • About Us
  • Contact Sales
  • Reviews
  • Uptime
  • We're Hiring

Copyright © 2023 NameHero, LLC. All rights reserved.

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