All Products
Search
Document Center

CDN:Usage notes on ConfigId

Last Updated:Mar 14, 2024

After you call the BatchSetCdnDomainConfig or SetCdnDomainStagingConfig operation to configure a feature for a domain name, a unique configuration ID (ConfigId) is generated. You can use this configuration ID to update or delete settings. This topic describes how to generate, query, and use a configuration ID.

Usage notes

Feature

Description

Generate a configuration ID

Call the BatchSetCdnDomainConfig or SetCdnDomainStagingConfig operation. If the operation succeeds, a configuration ID is generated.

Query configuration IDs

Call the DescribeCdnDomainConfigs or DescribeCdnDomainStagingConfig operation. If the operation succeeds, a configuration ID is returned.

Use a configuration ID to update settings

Call the BatchSetCdnDomainConfig or SetCdnDomainStagingConfig operation to update settings based on a specified configuration ID.

Use a configuration ID to delete settings

Call the DeleteSpecificConfig or DeleteSpecificStagingConfig operation to delete settings based on a specified configuration ID.

Generate a configuration ID

  • Configure a single feature rule:

    • Call the BatchSetCdnDomainConfig operation to configure a specific feature for a domain name. If the operation succeeds, a configuration ID is returned.

    • Call the SetCdnDomainStagingConfig operation to configure a specific feature for a domain name. However, no configuration ID is returned after the operation succeeds. You must call the DescribeCdnDomainStagingConfig operation to query the configuration ID.

    Scenario: The domain name example.com is used as an example. Enable points of presence (POPs) to inform clients that the content returned to the clients does not need to be cached.

    Example: Set the set_resp_header parameter for the domain name example.com: key=Cache-Control,value=no-cache. Sample request:

    action: BatchSetCdnDomainConfig
    params: {
        "Functions": [{
            "functionArgs": [{
                    "argName": "value",
                    "argValue": "no-cache"
                },
                {
                    "argName": "key",
                    "argValue": "Cache-Control"
                }
            ],
            "functionName": "set_resp_header"
        }],
        "domainNames": "example.com"
    }
    product: cdn

    If the operation succeeds, a configuration ID is returned.

    {
        "code": "200", 
        "data": {
    "DomainConfigList": {
                "DomainConfigModel": [
                    {
                        "FunctionName": "set_resp_header", 
                        "DomainName": "example.com", 
                        "ConfigId": 19571990834****
                    }
                ]
            }, 
            "RequestId": "4FF61A1D-E697-5E6C-9E5D-7D1E1529****"
        }, 
        "httpStatusCode": "200", 
        "requestId": "4FF61A1D-E697-5E6C-9E5D-7D1E1529****", 
        "successResponse": true
    }
  • Some features support more than one rule. The following example shows how to add multiple rules at a time:

    Example: Set the set_resp_header parameter for the domain name example.aliyundoc.com and add the following two rules:

    • Rule 1: Enable POPs to inform clients that the content returned to the clients does not need to be cached.

      Parameter settings: key=Cache-Control,value=no-cache.

    • Rule 2: Enable POPs to inform clients that the content returned to the clients is of the text type.

      Parameter settings: key=Content-Type,value=text/plain.

    Sample request:

    action: BatchSetCdnDomainConfig
    params: {
        "domainNames": "example.aliyundoc.com",
        "functions": [
            {
                "functionArgs": [
                    {
                        "ArgValue": "Cache-Control",
                        "ArgName": "key"
                    },
                    {
                        "ArgValue": "no-cache",
                        "ArgName": "value"
                    }
                ],
               "functionName": "set_resp_header"
           },
           {
                "functionArgs": [
                   {
                        "ArgValue": "Content-Type",
                        "ArgName": "key"
                    },
                    {
                        "ArgValue": "text/plain",
                        "ArgName": "value"
                    }
                ],
                "functionName": "set_resp_header"
            }
        ]
    }
    product: cdn

    If the operation succeeds, two configuration IDs are returned.

    {
        "code":"200",
        "data":{
            "DomainConfigList":{
                "DomainConfigModel":[
                    {
                        "FunctionName":"set_resp_header",
                        "DomainName":"example.aliyundoc.com",
                        "ConfigId":20953663204****
                    },
                    {
                        "FunctionName":"set_resp_header",
                        "DomainName":"example.aliyundoc.com",
                        "ConfigId":20953663204****
                    }
                ]
            },
            "RequestId":"69A79ACE-FD8E-5993-9CEA-7AAB2F08****"
        },
        "httpStatusCode":"200",
        "requestId":"69A79ACE-FD8E-5993-9CEA-7AAB2F08****",
        "successResponse":true
    }

Query configuration IDs

Call the DescribeCdnDomainConfigs or DescribeCdnDomainStagingConfig operation. If the operation succeeds, a configuration ID is returned.

Example: Query the settings of set_resp_header for the domain name example.aliyundoc.com. Sample request:

action: DescribeCdnDomainConfigs
params: {
    "domainName": "example.aliyundoc.com",
    "functionNames": "set_resp_header"
}
product: cdn

A configuration ID is returned.

{
    "code": "200",
    "data": {
        "RequestId": "51B7DF03-A7AE-56ED-BF1E-D16F6A6B****",
        "DomainConfigs": {
            "DomainConfig": [{
                "Status": "configuring",
                "FunctionName": "set_resp_header",
                "FunctionArgs": {
                    "FunctionArg": [{
                            "ArgValue": "no-cache",
                            "ArgName": "value"
                        },
                        {
                            "ArgValue": "Cache-Control",
                            "ArgName": "key"
                        }
                    ]
                },
                "ConfigId": 19572306654****
            }]
        }
    },
    "httpStatusCode": "200",
    "requestId": "51B7DF03-A7AE-56ED-BF1E-D16F6A6B****",
    "successResponse": true
}

Use a configuration ID to update settings

Call the BatchSetCdnDomainConfig or SetCdnDomainStagingConfig to update settings based on a specified configuration ID.

Scenario: The domain name example.com is used as an example. Enable POPs to cache content responded to clients for one hour.

Example: Set the set_resp_header parameter for the domain name example.com: key=Cache-Control,value=max-age=3600. Sample request:

action: BatchSetCdnDomainConfig 
params: {
    "Functions": [
        {
            "functionArgs": [
                {
                    "argName": "value", 
                    "argValue": "max-age=3600"
                }, 
                {
                    "argName": "key", 
                    "argValue": "Cache-Control"
                }
            ], 
            "functionName": "set_resp_header", 
            "ConfigId": 19571990834****
        }
    ], 
    "domainNames": "example.com"
}
product: cdn

Use a configuration ID to delete settings

Call the DeleteSpecificConfig or DeleteSpecificStagingConfig operation to delete settings based on a specified configuration ID.

Example: Delete the settings of the set_req_header parameter for the domain name example.aliyundoc.com. Sample request:

action: DeleteSpecificConfig
params: {
    "ConfigId": 19571990834****, 
    "functionName": "set_resp_header", 
    "domainName": "example.aliyundoc.com"
}
product: cdn