Device Groups
Device Groups is an Edge Application capability that allows you to identify the devices that will send requests to your application and categorize them into groups. You can use Device Groups to set custom application behaviors and cache policies based on the groups you create.
1. How it works
Users that access applications created in Real-Time Manager (RTM) send Azion data via HTTP request headers. The User-Agent
header stores information on the user’s browser, operating system, version, and manufacturer. This header follows the syntax:
User-Agent: <product>/<product-version> <comment>
Where:
product
: product identifier.product-version
: version number of the product.comment
: system information, platform name and details, and extensions.
For instance, the following User-Agent
header indicates that a Windows machine has accessed the application using Mozilla Firefox:
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0
Device Groups works by matching the contents of the User-Agent
header to a regular expression of your choice. Once you’ve created a device group, you can configure a rule or a cache policy specifically for the devices within the group.
To create a device group, follow these steps:
- Access RTM.
- On the upper-left corner, go to Products menu > Edge Application.
- Click on the application you want to configure or build a new one.
- Select the Device Groups tab.
- Click the Add Device Group button.
- Name your device group.
- Add what contents the User Agent header should contain in regex format following PCRE standard.
- Click the Save button.
2. Usage
Device Groups can be used to identify the devices that send requests to your application and categorize them accordingly.
For example, you can create a device group called Mobile whose regular expression must match the contents within the User-Agent
header that identifies mobile devices. The following expression can be used to identify most of the existing mobile devices:
(Mobile|iP(hone|od)|BlackBerry|IEMobile)
The Mobile device group can then be referenced in your application’s Rules Engine tab or in the Cache Settings tab.
2.1. Rules Engine
When you create a rule, you can use the variable ${device_group}
to define which behaviors your application should perform for the device groups you’ve created. To reference a device group, you can add its name to the argument section after you select the desired comparison operator.
To activate this variable, you must enable Application Acceleration.
The following criteria identifies whether the user request comes from a device that matches a device group named Mobile:
Variable | Comparison Operator | Argument | |
---|---|---|---|
If | ${device_group} |
is equal to | Mobile |
Rules Engine can also identify devices using the ${http_user_agent}
variable directly by adding a string or regular expression as an argument. That way, you can identify specific devices without having to dedicate a device group to them.
The following criteria identifies whether the user request comes from an iPhone device:
Variable | Comparison Operator | Argument | |
---|---|---|---|
If | ${http_user_agent} |
matches | (?i)iPhone |
Find out more about Rules Engine.
2.2. Adaptive Delivery
In the Cache Settings tab of your Edge Application, you can reference an existing device group for Adaptive Delivery.
When choosing the option Content varies by some Device Groups (Whitelist), you are allowing Azion to keep device-based variations of its objects in the cache.
You can choose one or more device groups to apply the same Adaptive Delivery policies. To activate Adaptive Delivery, contact our Sales team.
Find out more about Cache Settings.
3. Proritization
Device Groups will prioritize matches first-to-last, regardless of the order within the User-Agent
header from the request. Given the following list of device groups:
Device group | Regular expression |
---|---|
Mobile | (Mobile|Android) |
Tablet | (iPad|Android) |
Desktop | (Chrome|Mozilla) |
If the request is made by a device that contains Android Tablet Mobile (Mozilla Firefox)
in its header, the words Android
and Mobile
will match the Mobile group.
However, for a request from iPad Apple Webkit Mobile
, the device will be identified as Mobile owing to the presence of Mobile
within the request, despite iPad
matching the Tablet device group.
When setting up your rules, keep in mind that User-Agent
headers for different devices can sometimes contain the same words. For instance: Google Chrome Android
likely came from a mobile device while Google Chrome Symbian
likely belongs to a desktop; both used the same Google Chrome application to access the application. Make sure to use precise wording when grouping devices.
Didn’t find what you were looking for? Open a support ticket.