Create a rule for a CDN resource: manually or from a template

How to add a rule: basic settings

How Rules interact with the resource settings

Rule creating from a template 

Rules examples

 

How to add a rule: basic settings

Use Rules to set up custom settings for certain file types or paths. 

1. In the resource settings, go to the Rules tab, click the Create rule button and choose Create blank rule.

____________________.jpg

2. Specify a rule name.

3. Specify a regular expression starting with ^/ or /

match_criteria.jpg

4. Choose the origin and origin pull protocol.

Note! These parameters can be inherited from the resource settings.

origin.jpg

6. Click the Add option button in the Options section to select the required options.

add_option.jpg

 

How Rules interact with the resource settings

1. If options are not added in Rule, the options are inherited from the resource settings.

For example, if you do not add options in the Rule for caching settings, the caching settings for the content specified in the rule will be inherited from the resource settings.

2. If the option is added to Rule but disabled, it is disabled for the Rule. 

If you add an option in a rule and disable it, the option will be disabled for the rule. The option parameters from the resource settings will not be taken into account for the content specified in the rule.

For example:

  • In the resource settings, the Country access policy option is added with the Allow by default, RU values. It means that access to content is limited for Russia.

allow_access.jpg

  • In the Rule settings, the Country access policy option is added but disabled.

    disabled.jpg

As a result, access for Russia will be limited to all content, except for that specified in the Rule settings.

3. If an option is added to a rule, its value set in the resource settings is overridden.

For example:

  • In the resource settings, the Browser Caching option is added with the  CDN controlled, 4 days values.

browser_caching_4_days.jpg

  • In the Rule settings, the Browser Caching option is added with the CDN controlled, 30 minutes values.

30_minutes.jpg

The content specified in the Rule will be cached in the browser for 30 minutes, the rest of the content - for 4 days.

 

Rule creating from a template 

You can create a rule from a prepared template. 

1. In the resource settings, go to the Rules tab and click Create rule button.

2. Select the desired template: added by account users or a system template.

template.jpg3. Make changes, if necessary, and save the rule. 

 

Rules Examples

Cache Settings

For example, to forbid caching of jpg, css, js files in CDN enter .*.(jpg|css|js)$ to the Rule Pattern:

__________________________.jpg

Add the CDN caching option with the CDN controlled and Do not cache values.

do_not_cache_cdn.jpg

 

HTTP headers

To set up HTTP-header Access-Control-Allow-Origin only for ttf files enter this to the Rule Pattern:

_______ttf_____.jpg

Add the CORS header support option.

cors_eng.jpg

You can add the header to all requests or just to the requests from the specified domains.

Read more about this option.

 

Was this article helpful?
Recently viewed articles