Overview

Property configuration rules and includes use behaviors to determine the action taken when specific conditions are met. The options you choose define your behavior and the criteria that trigger the behavior's action.

ūüĎć

Tip

The Terraform VS Code Extension includes a dynamic edit feature that pulls in Property documentation and provides a list of available behaviors and match criteria.

Behaviors

Within rules, your behaviors are represented as an array of objects, each object a single behavior with its options.

Default rule behaviors

The default rule is our required base rule. Behaviors you set at the default rule level apply to all requests for your property hostnames unless another rule overrides the settings.

For example, a default rule has two behaviors, origin and cpCode. For all the property's hostnames, the behavior of the origin and CP code is governed by their defined options.

"rules": {
  "name": "default",
  "behaviors": [
    {
      "name": "origin",
      "options": {
        "originType": "CUSTOMER",
        "hostname": "example.com",
        "forwardHostHeader": "REQUEST_HOST_HEADER",
        "cacheKeyHostname": "ORIGIN_HOSTNAME",
        "compress": true,
        "tcipEnabled": false,
        "httpPort": 80
      }
    },
    {
      "name": "cpCode",
      "options": {
        "value": {
          "id": 12345,
          "name": "main site"
        }
      }
    }
  ]
}

Child rules

Nested within your rules are child rules and their behaviors.

Here, a child rule of Compress Text Content has a behavior of gzipResponse with an option.

"children": [
    {
      "name": "Compress Text Content",
      "behaviors": [
        {
          "name": "gzipResponse",
          "options": { "behavior": "ALWAYS" }
        }
      ]
    }
  ]

Criteria

Criteria are the situational conditions that trigger a behavior's action. Except for the default rule, you can have criteria for rules at any level of your rule tree.

In the child rule example above, the compress text content rule has a behavior that's set to always zip content, but if not all content types fit the rule, choose which types do in the criteria.

"criteria": [
  {
    "name": "contentType",
    "options": {
      "matchOperator": "IS_ONE_OF",
      "matchWildcard": true,
      "matchCaseSensitive": false,
      "values": [
        "text/html*",
        "text/css*",
        "application/x-javascript*"
      ]
    }
  }
]

Complete tree

Your property configuration, rules, child rules, and their behaviors and criteria, work together as a rule tree to shape a solution.

The sample code presented throughout this page works together to deliver a solution that uses a customer's origin as the source of truth, its hostname to build out the keys for cached content, and directs requests for information through port 80.

The solution also collects all forwarded request metadata and compresses specific content types to reduce the amount of data sent in responses and increase display speed.

"rules": {
  "name": "default",
  "options": {
      "is_secure": false
  },
  "behaviors": [
    {
      "name": "origin",
      "options": {
        "originType": "CUSTOMER", 
        "hostname": "example.com", 
        "forwardHostHeader": "REQUEST_HOST_HEADER", 
        "cacheKeyHostname": "ORIGIN_HOSTNAME", 
        "compress": true, 
        "enable_true_client_ip": false,
        "httpPort": 80 
      }
    },
    {
      "name": "cpCode", 
      "options": {
        "value": {
            "id": 12345, //my code
            "name": "main site"
        }
      }
    }
  ],
  "children": [
    {
      "name": "Compress Text Content",
      "behaviors": [
        {
          "name": "gzipResponse",
          "options": { "behavior": "ALWAYS" }
        }
      ],
      "criteria": [
        {
          "name": "contentType",
          "options": {
            "matchOperator": "IS_ONE_OF",
            "matchWildcard": true,
            "matchCaseSensitive": false,
            "values": [
              "text/html*",
              "text/css*",
              "application/x-javascript*"
            ]
          }
        }
      ]
    }
  ]
}