Skip to main content

Page Rules

You can activate the Arvancloud CDN service for your domain by adding it to your panel and turning on the cloud option. The system will automatically turn on the default settings for all of your subdomains. For instance, all of your static files will start caching.

You can change the default settings (for example, when you don’t want specific files to be cached, or a header to be ignored) by creating rules in the Page Rules section of your panel.

As the image shows, a default rule matches all of the requests from the main domain and subdomains in their caching settings, WAF, firewall, etc.

The rules should follow this pattern: scheme ://hostname/path For example:

https ://subdomain.test.com/somepage

It is important to note that the request will only match one rule (the first one that matches the request). Therefore, all settings must be included in that same rule. The rules are analyzed from top to bottom. Now, hypothetically if there is a website with the address dev.test.com and you want to disable caching for the /static/ address to see the changes of the static files in real-time. You need to create a rule such as the following:

Use * for Wildcard so that all requests beginning with dev.test.com/static/ will match the rule. Your page rules will end up looking like this:

Using Regular Expressions in Defining Rules

You can use brackets [ ] to match specific characters (numbers and letters) with a rule.

Example 1: Setting a rule to consider the following URLs simultaneously: https: //www .example.com/fa

https: //www .example.com/Fa

Write down the rule like the following, https: //example.com/[fF]a/*

Example 2: Setting a rule to match the following URL with a number: https: //example.com/users/2xxxx Write down the rule like this, https: //example.com/users/[0-9]*

Example 3: To set a rule matching all pages starting with a-z small letters, write the rule like the following, https: //example.com/[a-z]/*

Please note that the rules are case-sensitive.

If you want the above rule to match all pages starting with capital A-Z letters, you need to write a different rule and write A-Z inside the brackets.

If you don’t begin a rule with HTTP or HTTPS, the rule will be applied for both URLs by default. For example: www .example.com/*

If you want to apply to rule only to the homepage, it should go like this: www .example.com/

The following features are included in the Page Rules:

  • Caching settings

    • Files cache time in the CDN service
    • Cache time in the browser
    • Caching pages with a set-cookie (for HTML pages)
  • Web acceleration If your website content needs acceleration, you can activate it here.

    You can only accelerate static files such as CSS, JS, JPG, PNG, and GIF (files that can be minified).

  • Security Settings

    • Web Application Firewall: activation will apply the WAF rules
    • DDoS Status: activation will apply general DDoS settings
    • Firewall Settings: allow access based on country or IP address
  • Proxy Settings

  • Send Traffic to Load Balancer: set a different Origin from DNS for a specific rule. At least one cluster must be present in the load balancing section.

  • Header Settings: sometimes, a specific header needs to be sent to your website (such as Host Header), or a new header must be sent to the user (such as allow-access-origin), or the header needs to be hidden from the user. All of these can be configured in the header settings.

  • Redirect: you can redirect selected requests with 301, 302, and 307 status codes.

  • Secure link: you can make a domain or URL accessible only for users with certain IPs and for a limited time.

Page Rules Cache Purge

You can delete cached files of a certain page file. The purge only includes cached files that have been cached as the result of this page rule. To delete the page rules cache, go to the page rules section of your panel under the CDN service and click on Delete Cache.

This feature is only available to the users of CDN service’s Professional Plan.

Redirect Using Variables

You can apply advanced settings in the automatic redirection of requests from a domain to another one using 301, 302, and 307 status codes. Using variables allows easy and flexible application of changes. Consult the Redirection Guide to learn how to use this method.

Timeout Settings

You can change the default timeout between the CDN edge servers and the main server. By using this feature, you will be able to change the interval of receiving the Timeout message in three different times:

  • The connection timeout between the CDN edge servers and the main server

  • The read timeout of waiting for the response from the main server

  • Write timeout when writing the data in the main server

For this purpose, create a new rule in the Page Rules section of your Arvancloud account. Enter the address and priority and choose the Timeout duration in seconds for each of the mentioned types and click Add.

The timeout settings are available to users on the Professional Plan. Otherwise, you need to upgrade your plan before accessing it.

Apply Cache Settings from Main Server

The CDN service responds to users’ requests through the cache servers between the user’s browser and the website’s main server. This is why you might need to configure the caching settings of your main server to manage your website’s content better. For instance, you can change the revalidation time of a file so that those files are not cached on the CDN edge servers. You can use Arvancloud CDN’s Origin Cache-Control to manage the cache settings of the origin server.

How Origin Cache-Control Works

Typically, our CDN service CDN sends a request to the main server of the website to cache the content. Then the response will be sent in HTTP showing the Caching parameters. Applying the Cache settings from the origin server adds a cache-control header and sends more detailed instructions to the CDN edge servers, such as caching duration or specifying caching for certain requests.

Types of Cache-Control Headers

These headers can be interpreted by the Origin Cache-Control, showing parameters of how to cache the resources:

  • Max-age: the cache expiration date will be determined by the origin server. When it is expired, the edge servers will send a validation request for the cached file.

  • Public: this parameter in the response header will cache the content for all requests irrespective of previous instructions, even when it is not possible to cache the content.

  • Private: the content will not be cached by the edge servers, and the response destination is a specific request. Therefore, the caching happens only in the browser.

  • No-cache: the content is stored on the servers, but each request starts a complete validation process.

  • No-store: the content will not be cached anywhere, and each request must follow the complete send and receive process to the main server.

  • Min-uses: after a certain number of requests, the content will be cached on the edge servers.

  • S-max: the edge servers will change the expiration time to this parameter using max-age.

  • Must-revalidate: the content in the header must be validated by the main server.

For example, an HTTP header with the following parameters causes the edge servers to cache the content on all servers and request revalidation after 36000 seconds.

Control-Cache: public, max-age=36000

Activating Origin Cache-Control

Go to the Page Rules in your Arvancloud account under the CDN service. Then, click on Create Page Rules and enter the address or the domain to activate the feature.

The cache-control feature is only available in the Enterprise Plan. If you are using another plan, you need to upgrade it before accessing this feature.