1. Home
  2. /
  3. WEBDEV
  4. /
  5. CMS Management
  6. /
  7. Cloudflare Rules

Cloudflare Rules

1. Procedure Title

Name of the Process: Setting Up Cloudflare Page Rules

2. Purpose

Brief Description: To configure Cloudflare Page Rules to optimize the performance and security of a WordPress site as per the provided requirements and guidelines.

3. Scope

Involved Areas: Web Development

4. Responsibilities

  • Web Developer
  • Configures and manages the Cloudflare Page Rules.
  • Monitors the performance and security impact of the configured rules.
  • Verifies the compatibility of page rules with the site’s structure.

 

5. Definitions and Key Terms

Glossary:

  • Page Rules: A feature in Cloudflare that allows specific actions to be applied to URL patterns.
  • Browser Cache TTL: Defines the time a browser should cache a resource.
  • HTTPS: Secure communication protocol to encrypt data.
  • 301 Redirect: A permanent redirection of one URL to another.

6. Procedure Details

6.1. Preparation and Prerequisites

  • Access to the Cloudflare dashboard.
  • Active domain on Cloudflare.
  • Understanding of the site’s structure and requirements.

6.2 Timeline for Task Completion

  • Estimated Time:
  • Initial Setup: 15-20 minutes per rule.
  • Testing and Monitoring: 10-15 minutes.
  • Frequency: Configured once, with periodic reviews.
  • Review Schedule: Quarterly or whenever changes are made to the site’s structure.

6.3. Step-by-Step Procedure

Steps to Configure Page Rules

Steps to Configure:

  • Log in to the Cloudflare dashboard.
  • Navigate to the Rules section and select Page Rules.
  • Click Create Page Rule.


 

Rule 1: Browser Cache TTL

  • URL Pattern: https://www.example.com/*

  • Action: Browser Cache TTL: 2 minutes

     

  1. Enter the URL pattern: https://www.example.com/*.

  2. Set the action Browser Cache TTL to 2 minutes.

  3. Save the rule.

Justification:

  • A short cache TTL ensures quick updates to content while benefiting from cached resources for frequent visitors.

Rule 2: Always Use HTTPS

  • URL Pattern: http://*example.com/*
  • Action: Always Use HTTPS

Steps to Configure:

  1. Create another Page Rule.

  2. Enter the URL pattern: http://*example.com/*.

  3. Select the action Always Use HTTPS.

  4. Save the rule.

Justification:

  • Forces all visitors to access the site via HTTPS, ensuring secure communication and improving SEO rankings.

Rule 3: Forwarding URL (301 Redirect)

  • URL Pattern: https://example.com/*
  • Action: Forwarding URL (Status Code: 301) to https://www.example.com/$1

Steps to Configure:

  1. Create another Page Rule.

  2. Enter the URL pattern: https://example.com/*.

  3. Select the action Forwarding URL.

  4. Choose the Status Code 301 – Permanent Redirect.

  5. Enter the target URL: https://www.example.com/$1.

  6. Save the rule.

Justification:

Redirects all traffic from the non-www version to the www version of the site to consolidate SEO value and avoid duplicate content issues.

Step 2: Notes for Implementation

  • Rule Order: Ensure the rules are ordered based on priority, as only one rule will trigger per request. Place the redirect rules before other caching or performance-related rules.

  • Testing: After configuring the rules, test:

  • HTTPS enforcement.
  • Redirection from non-www to www.
  • Cache behavior for updated content.
  • Monitoring: Use Cloudflare Analytics to track rule performance and make adjustments if necessary.

By following these steps, you will implement the exact Page Rules setup as shown in the screenshot, ensuring optimal performance and secure access for your WordPress site.

 

6.4. Tools and Resources

  • Cloudflare dashboard access.
  • Site structure documentation for URL patterns.

7. Safety and Compliance Measures

Applicable Regulations:

  • Adhere to organizational data security policies when configuring HTTPS.
  • Ensure compliance with SEO guidelines to avoid penalties from misconfigurations.

8. Quality Control and Evaluation Metrics

Performance Indicators:

  • Successful redirection of traffic based on configured rules.
  • Secure HTTPS access for all site pages.
  • Improved site performance metrics in Cloudflare Analytics.

9. Exception and Problem Handling

Common Issues and Solutions:

  1. Rule Not Triggering

    • Cause: Incorrect URL pattern or rule order.

    • Solution: Double-check the URL pattern and adjust rule priority.

  2. Unexpected Redirects

    • Cause: Conflicting rules or misconfigured patterns.

    • Solution: Review and resolve conflicts by modifying the rule order or patterns.

  3. Slow Site Performance

    • Cause: Incorrect cache settings.

    • Solution: Reassess the Browser Cache TTL and other related rules.

10. Documentation and Record Keeping

Documentation Requirements:

  • Maintain a log of all configured rules, including date and purpose.
  • Record testing outcomes and any issues encountered during implementation.
  • Save screenshots of the rule configurations for reference.

11. Procedure Review and Update

Review Frequency:

This procedure should be reviewed quarterly or when significant changes are made to the site’s structure or requirements.

 

 

Still stuck? Contact

How can we help?