How to set Page Rules in Cloudflare to prevent cache of few pages

Category : General

Want to disable cache for few pages of your website? Want to set 301 redirect rules from Cloudflare? All these requirements can be fulfilled using Cloudflare Page rules.

Requirements

  • Cloudflare Account and domain added

Procedure

Example #1

  1. Login to your Cloudflare account
  2. Select the domain for which you want to set Page Rules
  3. Tap on Page Rules Option on Above bar and tap ‘Create Page Rule’ Button
    Page Rules Create Page Rule
  4. Inside URL TextBox Enter
    http://www.domain.tld/*
    Page Rule Settings
  5. Set the rule settings to “Always HTTPS”. This will force your every webpage, subdomain to redirect to HTTPS.
  6. Save and Deploy

Example #2

Adjust Cache level using Page Rules

Similarly, you can disable “Cache Level” for some of the pages on your website like wp-admin and wp-login.php pages of the WordPress website.

For disabling cache for wp-admin panel follow steps #1 to #4 above first followed by below steps.

  1. Inside URL TextBox Enter
    https://www.domain.tld/wp-login.php*
  2. Set the rule settings to “Cache Level”  and in next field “Bypass”Page Rules List
  3. Save and Deploy
  4. Similarly, create another page rule for URL and save to deploy.
    https://www.domain.tld/wp-admin/*

Note – The Free plan under Cloudflare allow 3-page rules.

So this how page rules are set in Cloudflare for the domain