Resources

CDN edge rules

Edge rules change how the CDN handles requests that match a condition, before they reach the cache or the origin. Each rule has a trigger, one or more patterns, and an action. Rules are managed from the Edge rules tab of a CDN.

Rule structure

PartWhat it does
Enable RuleOn by default. Turn it off to save the rule as a draft without activating it.
Trigger typeWhat the rule inspects. See the trigger list below.
Pattern matchingMatch any: the rule fires if any pattern matches. Match all: every pattern must match. Match none: the rule fires only when no pattern matches.
PatternsOne or more values to compare against. * is a wildcard.
ActionWhat happens when the trigger matches. See the action list below.
DescriptionOptional note for your own reference.

Trigger types

TriggerMatches againstExample pattern
URLThe full request URL.*/images/*
URL extensionThe file extension of the requested path.jpg
Request headerA header sent by the visitor.Header name and value pattern.
Country codeThe two-letter country code of the visitor's IP address.DE
Remote IPThe visitor's IP address.203.0.113.0/24

Actions

ActionWhat it does
RedirectSends the visitor to another URL with a status code of 301, 302, 307, or 308. The redirect URL can include variables.
Override edge cache timeSets how long the edge keeps the matching content, overriding the origin's Cache-Control. The browser cache time is set to the same value unless an Override browser cache time rule also matches. Applies to content fetched after the rule is created.
Override browser cache timeSets the Cache-Control max-age sent to the visitor's browser.
Force SSLRedirects matching HTTP requests to HTTPS.
Block requestDenies the request.
Set response headerAdds or overrides a header on the response sent to the visitor.
Set request headerAdds or overrides a header on the request sent to the origin.
Ignore query stringTreats URLs with different query strings as the same cached object.

Variables

Redirect URLs and header values can include variables that are replaced per request.

VariableValue
%{Request.Method}HTTP method
%{Request.Path}Full request path including query string
%{Request.QueryString}Query string only
%{Url.Hostname}Host portion of the URL
%{Url.Directory}Directory portion of the path
%{Url.FileName}Filename without extension
%{Url.Extension}File extension
%{Path.0}, %{Path.0-2}, %{Path.3-}, %{Path.-1}Path segments by index, range, or from the end
%{Query.name}Value of the name query parameter
%{RequestHeaders.Name}Value of a request header, for example %{RequestHeaders.User-Agent}
%{User.IP}Visitor IP address
%{User.CountryCode}Visitor country code
%{Server.ZoneCode}Edge zone serving the request
%{Server.ID}Edge server identifier

For worked examples, see How to get started with UpCloud CDN.

Can't find what you're looking for?

For more help you can contact our awesome 24/7 support team