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 and click Add rule.
2. Select the Match Type:
- For Literal enter the URL, which the rule will be applied to, to the Rule pattern field.
- For Regular Expression specify the path or file types by the regular expression.
Rules settings are equal to the Resource Settings.
How Rules interact with the resource settings
1. If an option isn't added in Rule, the value is inherited from the resource settings.
For example, if you do not add options in the Rule for caching settings, the caching settings for content set in the rule will be inherited from the resource settings:
2. If the option is added to Rule and disabled, the option won't set up to the Rule. Option value that is specified in resource settings isn't inherited.
For example, in the resource settings access to the content is restricted from Russia, and in Rule Country Access Policy slider is on the left and the option is grey. Then, no country restrictions will be applied to the content specified in the Rule.
3. If the option is added to the Rule and has its own value, to the Rule content will applied value you set up in Rule.
For example, in the resource settings Browser Caching is 4 days and in the Rule is 30 minutes, content specified in Rules will be cached for 30 minutes and all the other 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 the arrow next to the Add rule button.
2. Select the desired template: added by account users or a system template.
3. Make changes, if necessary and save the rule.
For example, to forbid caching of jpg, css, js files in CDN enter this to the Rule Pattern:
In the Cache section choose Do not cache in the CDN Caching option.
Click Add Rule.
To set up HTTP-header Access-Control-Allow-Origin only for ttf files enter this to the Rule Pattern:
Then go to the Access (Security) section, click Add Option and choose Access-Control-Allow-Origin Header option.
You can add the header to all requests or just to the requests from the specified domains. Read more about this option.
! Notice that your main settings do not automatically apply to the Rules. For example, if you have content access restrictions, you need to add them to the Rule settings, or the content mentioned in the Rules will be available.