How to Set Up Page Rules on VergeCloud for Website Optimization and Control

Configuring Page Rules on VergeCloud: Optimize and Control Your Website’s Performance

VergeCloud Page Rules

Page Rules allow you to configure specific behaviors for your domain on VergeCloud’s CDN service. By adding your domain to your VergeCloud panel and enabling the cloud option, the system automatically applies default settings for all your subdomains. This means that static files will begin to cache automatically.

Glossary

  • CDN (Content Delivery Network): A network of servers that delivers web content based on the geographic location of the user.
  • Cache: A storage layer that saves copies of files or resources to speed up future requests.
  • Page Rule: A set of conditions and actions applied to specific URLs to control caching and other behaviors.
  • Wildcard: A character that can represent one or more characters in a string (e.g., *).
  • Redirect: A process that automatically sends users from one URL to another.
  • Timeout: A specified duration after which a connection or request will fail if no response is received.

Real Usage Scenarios

For example, suppose you have a website at dev.test.com and you want to disable caching for the /static/ path to observe changes in real-time. You would create a rule to disable caching specifically for this path, ensuring that updates are visible without delay.

Field/Option Descriptions

Creating Page Rules

To create effective page rules, follow this syntax: scheme://hostname/path. For instance:

https://subdomain.test.com/somepage

Note that the request will only match the first rule that fits. All necessary settings must be included within that same rule, as rules are evaluated from top to bottom.

Using Wildcards

Use * for wildcards to match all requests that begin with a specific pattern:

dev.test.com/static/*

Using Regular Expressions

Brackets [ ] can be used to match specific characters. Here are some examples:

  • To match both https://www.example.com/fa and https://www.example.com/Fa, use:
    https://example.com/[fF]a/*
  • To match a URL containing a number:
    https://example.com/users/[0-9]*
  • To match all pages starting with lowercase letters a-z:
    https://example.com/[a-z]/*

Rules are case-sensitive. For uppercase letters, a separate rule must be created with A-Z included.

Page Rules Features

  • Caching Settings: Manage cache times for files and browsers.
  • Web Acceleration: Enable acceleration for static files like CSS and images.
  • Security Settings: Activate WAF and configure firewall settings.
  • Proxy Settings: Redirect traffic and modify headers.
  • Redirect: Implement HTTP status code redirects (301, 302, 307).
  • Secure Link: Limit access to certain users based on IP.

How to Add/Edit/Use the Feature

Step-by-Step Guide

  1. Log in to your VergeCloud panel. 
  2. Navigate to the Page Rules section. 
  3. Click on "Create Page Rules." 
  4. Enter the desired URL and configure your settings. 
  5. Save your changes.

API Example

To configure a caching rule via API, use the following cURL command:

curl -X POST "https://api.vergecloud.com/v1/page-rules" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
    "url": "https://dev.test.com/static/*",
    "cache": {
        "enabled": true,
        "ttl": 3600
    }
}'

Testing and Validation

To verify your Page Rules setup, follow these steps:

  1. Use curl to check the response headers and confirm caching behavior:
  2. curl -I https://dev.test.com/static/somefile.jpg
  3. Utilize dig to analyze DNS settings:
  4. dig dev.test.com
  5. Check the browser's developer tools for network requests to ensure that the correct caching headers are applied.

Page Rules Cache Purge

You can delete cached files for a specific page. To purge the cache, navigate to the Page Rules section in your VergeCloud panel and click on "Delete Cache." Note that this feature is only available for users on the Professional Plan.

Advanced Redirects Using Variables

To set up automatic redirection with advanced settings, refer to the Redirection Guide for detailed instructions on utilizing variables.

Timeout Settings

Modify the default timeout settings for the connection between CDN edge servers and your main server:

  1. Access the Page Rules section in your VergeCloud account. ![](image-placeholder.png)
  2. Enter the URL and priority.
  3. Select the timeout duration in seconds for connection, read, and write timeouts, then click "Add." ![](image-placeholder.png)

Note: Timeout settings are available to users on the Professional Plan. Upgrade is necessary for other plans.

Apply Cache Settings from Main Server

To enhance your website’s content management, you may need to configure cache settings from the origin server using the Origin Cache-Control header.

How Origin Cache-Control Works

The CDN requests your origin server to cache content, and the response includes caching parameters. Implementing Cache-Control settings provides detailed caching instructions to the edge servers.

Types of Cache-Control Headers

  • max-age: Determines cache expiration time.
  • public: Allows caching for all requests.
  • private: Restricts caching to specific requests only.
  • no-cache: Requires validation for each request.
  • no-store: Prevents caching entirely.
  • min-uses: Specifies cache activation after a number of requests.
  • s-max: Adjusts expiration time based on max-age.
  • must-revalidate: Requires validation by the main server.

Activating Origin Cache-Control

To enable the cache-control feature:

  1. Navigate to Page Rules in your VergeCloud account under the CDN service. ![](image-placeholder.png)
  2. Click on "Create Page Rules" and enter the URL or domain. ![](image-placeholder.png)

Note: This feature is only available in the Enterprise Plan. Upgrade is required for other plans.