Cloudflare offers varied features, one of which includes Cloudflare page rules. Cloudflare Page Rules is a powerful tool that allows you to modify your website performance by customizing how Cloudflare works for your domain. With Page Rules, you can do things like:
- Cache specific pages or assets for longer periods of time.
- Redirect users to different pages based on their location or device type.
- Rewrite URLs to make them more SEO-friendly.
- Block malicious traffic.
- And much more.
Cloudflare Page Rules feature offers a straightforward rule syntax, enabling you to define URL patterns for matching and specify the corresponding actions that Cloudflare should take. For example, you can create a rule to cache all pages within the /blog directory for a duration of 30 days, or even redirect users from www.example.com to example.com.
By utilizing Page Rules, you can significantly enhance your website’s performance, security, and SEO. If you haven’t explored this functionality yet, I strongly recommend giving it a try.
Here are some key benefits of implementing Cloudflare Page Rules:
- Enhanced Performance: Page Rules contribute to improved website performance by efficiently caching static assets and redirecting users to the nearest Cloudflare server.
- Increased Security: Strengthen your website’s security with Page Rules by blocking malicious traffic and employing URL rewriting techniques to make exploitation more challenging.
- Improved SEO: Leverage Page Rules to boost your website’s SEO by caching static assets and optimizing URL structures to make them more search engine friendly.
If you seek effective ways to optimize your website’s performance, security, and SEO, Cloudflare Page Rules present an excellent solution. So give them a try and witness the positive impact they can bring to your online presence.
But, before we go any further , you should be aware that the amount of allowed page rules is determined on the domain plan offered by the hosting providers, as indicated below.
How to Create and edit Cloudflare Page Rules
The first step is to learn how to create page rules. Here are the steps.
- Log in to your Cloudflare dashboard.
- Select the domain where you want to create the page rule.
- Click the Rules app.
- Click the Create Page Rule button on the Page Rules tab.
5. In the Page Rules, paste your URL, that select the Page Rules you want to apply.
6. Click on Save and Deploy Page Rules.
Now that you know how to create, lets learn to edit the Page Rules
To edit a page rule, follow these steps:
- Log in to your Cloudflare dashboard.
- Choose the domain for which you wish to change the page rule.
- Click the Rules.
- Locate the rule that you wish to change in the Page Rules tab.
- Click the Edit button (wrench icon).
- Make the necessary changes to the rule.
- Click Save.
8 Most Useful Cloudflare Page Rules
1. Always use HTTPS
Enable Always make use of the HTTPS functionality. When this option is enabled, any https:// URL is changed to https:// through a 301 redirect.
2. Browser Cache TTL
This feature lets you decide how long client browsers should keep cached resources available. The Cloudflare UI or API prohibits setting the Browser Cache TTL to 0 for domains that are not Enterprise domains.
You can set up for up to 1 year.
3. Cache Level – Everything
Every resource on a web page is treated as static using the “Cache Everything” option, which also caches all file types in addition to the normal Cloudflare content. Unless Edge Cache TTL is additionally defined in the Page Rule, respects cache headers from the origin web server. Cache Everything removes cookies from the origin web server response when used with an Edge Cache TTL > 0.
4. Security Level – High
A WordPress site’s login page shouldn’t be cached because it includes private data. Use the setting on your site as a result. To defend your page from web cache deception assaults, think about employing the Cache Deception Armour feature. To prevent overriding the cache instructions, make sure the Edge Cache TTL is off.
5. Forwarding URL
Redirects utilizing an HTTP 301/302 redirect from one URL to another. It’s really easy to use, and you can utilize the Forwarding URL setting to use affiliate links with it. Depending on what you choose.
6. Always Online
When enabled, Always Online makes your most crucial pages accessible even if your server goes down (for example, your homepage, contact information, terms of service, etc.).
7. Email Obfuscation
Email obfuscation is a useful tool to avoid spam since it will conceal your email address from bots while keeping it accessible to people.
Email obfuscation has the drawback of loading a JS file (email-decode.min.js) on each page, as you may notice in PageSpeed Insights. This is OK if your email address is shown across the site, such as in your footer, but it’s not ideal if you just provide it on the contact page. In this situation, you may configure a page rule to limit the use of email obfuscation to a certain page.
8. AJAX-Powered eCommerce Sites with Dynamic Content
eCommerce sites may contain dynamic content that is best not cached, but you should still cache all other stuff. Cloudflare suggests employing a cache everything page rule to cache all other requests after bypassing the cache for AJAX queries. The next page rule will be needed for this, but make sure the AJAX rule comes before the cache everything rule, which will come last.
Final Say
Cloudflare Page Rules offer an exceptional opportunity to optimize your website’s performance and security. By leveraging the power of Page Rules, you can enhance user experience, boost SEO rankings, and protect your site from various threats. Remember to start with basic rules and gradually experiment with more advanced configurations. As you gain familiarity with Cloudflare’s features, you’ll be better equipped to maximize the potential of Page Rules for your website’s success.
FAQs on Cloudflare Page Rules
1. Can I use Cloudflare Page Rules on the free plan?
Yes, Cloudflare Page Rules are available on both free and paid plans.
2. How many Page Rules can I create for my website?
The number of Page Rules allowed depends on your Cloudflare plan. Free plans offer three rules, while paid plans have more generous limits.
3. Will Page Rules impact my website’s SEO?
Page Rules can enhance your website’s SEO by enabling HTTPS, caching, and mobile redirection, among other optimizations.
4. Can I use regular expressions in Page Rules?
Yes, you can use regular expressions to create more complex and flexible triggers for your rules.
5. Can I revert changes made by a Page Rule easily?
Absolutely! You can disable or delete any Page Rule at any time to revert its effects.