All Products
Search
Document Center

Edge Security Acceleration:CreateCacheRule

Last Updated:Mar 23, 2026

Create a Site Cache Configuration.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request parameters

Parameter

Type

Required

Description

Example

SiteId

integer

Yes

The ID of the Site. Call the ListSites operation to obtain this ID.

340035003106221

SiteVersion

integer

No

The version of the Site's configuration. If the Site has versioning enabled, this parameter specifies which version the configuration applies to. The default is 0.

1

RuleName

string

No

The name of the Rule. This parameter is not required when adding a global configuration.

rule_example

RuleEnable

string

No

Indicates whether the Rule is enabled or disabled. This parameter is not required when adding a global configuration. Valid values:

  • on: Enabled.

  • off: Disabled.

on

Rule

string

No

The content of the Rule, a conditional expression that matches user requests. This parameter is not required when adding a global configuration. It supports two use cases:

  • To match all incoming requests, set the value to true.

  • To match specific requests, set the value to a custom expression. For example: (http.host eq "video.example.com")

(http.host eq \"video.example.com\")

BypassCache

string

No

The Bypass Cache mode. Valid values:

  • cache_all: Caches all requests.

  • bypass_all: Bypasses the cache for all requests.

cache_all

BrowserCacheMode

string

No

The Browser Cache mode. Valid values:

  • no_cache: Disables Browser Cache.

  • follow_origin: Honors the origin server's cache policy.

  • override_origin: Overrides the origin server's cache policy.

follow_origin

BrowserCacheTtl

string

No

The Browser Cache TTL (Time-To-Live), in seconds.

300

EdgeCacheMode

string

No

The cache mode for the Edge Node. Valid values:

  • follow_origin: Honors the origin server's cache policy if present. Otherwise, the default cache policy is used.

  • no_cache: Disables caching on the Edge Node.

  • override_origin: Overrides the origin server's cache policy.

  • follow_origin_bypass: Honors the origin server's cache policy if present. Otherwise, content is not cached.

  • follow_origin_override: Honors the origin server's cache policy if present. Otherwise, a custom Cache TTL is used.

follow_origin

EdgeCacheTtl

string

No

The Cache TTL (in seconds) for content on the Edge Node.

300

EdgeStatusCodeCacheTtl

string

No

The Cache TTL for specific status codes, in seconds.

  • You can set the Cache TTL for an individual status code. For example, 404=10 caches responses with a 404 status code for 10 seconds.

  • You can also set the Cache TTL for a series of status codes, such as 4xx or 5xx. For example, 4xx=10 caches all responses in the 400-series for 10 seconds.

4xx=10

SortQueryStringForCache

string

No

Specifies whether to sort query strings before generating the Cache Key. Disabled by default. Valid values:

  • on: Enabled.

  • off: Disabled.

on

QueryStringMode

string

No

Defines how to handle query strings when generating the Cache Key. Valid values:

  • ignore_all: Excludes all query strings from the Cache Key.

  • exclude_query_string: Excludes specific query strings from the Cache Key.

  • reserve_all: Default. Includes all query strings in the Cache Key.

  • include_query_string: Includes only specific query strings in the Cache Key.

reserve_all

QueryString

string

No

The specific query strings to include or exclude, depending on the QueryStringMode. Separate multiple query strings with a space.

example

IncludeHeader

string

No

The names of the headers to include in the Cache Key. This includes both the header name and its value. Separate multiple headers with a space.

example

IncludeCookie

string

No

The names of the cookies to include in the Cache Key. This includes both the cookie name and its value. Separate multiple cookies with a space.

cookie_exapmle

CacheReserveEligibility

string

No

Controls whether a request bypasses the Cache Reservation node during an Origin Fetch. Valid values:

  • bypass_cache_reserve: The request bypasses Cache Reservation.

  • eligible_for_cache_reserve: The request is eligible for Cache Reservation.

bypass_cache_reserve

CheckPresenceHeader

string

No

Specifies headers to check for presence when generating the Cache Key. If a specified header exists in the request, its name (case-insensitive) is included in the Cache Key. Separate multiple header names with a space.

headername

CheckPresenceCookie

string

No

Specifies cookies to check for presence when generating the Cache Key. If a specified cookie exists in the request, its name (case-insensitive) is included in the Cache Key. Separate multiple cookie names with a space.

cookiename

UserDeviceType

string

No

If enabled, includes the client's device type in the Cache Key. Valid values:

  • on: Enabled.

  • off: Disabled.

on

UserGeo

string

No

If enabled, includes the client's geographic location in the Cache Key. Valid values:

  • on: Enabled.

  • off: Disabled.

on

UserLanguage

string

No

If enabled, includes the client's language in the Cache Key. Valid values:

  • on: Enabled.

  • off: Disabled.

on

ServeStale

string

No

If enabled, allows the Edge Node to serve stale (expired) content when the Origin Server is unavailable. Valid values:

  • on: Enabled.

  • off: Disabled.

on

AdditionalCacheablePorts

string

No

Specifies additional ports where caching is enabled. Valid ports: 8880, 2052, 2082, 2086, 2095, 2053, 2083, 2087, 2096.

8880

CacheDeceptionArmor

string

No

If enabled, provides cache deception defense by validating content before caching it. Valid values:

  • on: Enabled.

  • off: Disabled.

on

Sequence

integer

No

The execution order of the Rule. A smaller value indicates a higher priority.

1

PostCache

string

No

Enables or disables caching for POST requests.

on

PostBodySizeLimit

string

No

The maximum size (in KB) of a request body to cache. The supported range is from 1 to 8 KB. If left empty, the default limit is 8 KB.

1

PostBodyCacheKey

string

No

Specifies how to handle the request body when generating the Cache Key for POST requests.

ignore

Response elements

Element

Type

Description

Example

object

The response object.

RequestId

string

The unique ID of the request.

04F0F334-1335-436C-A1D7-6C044FE73368

ConfigId

integer

The ID of the created cache rule.

352816096987136

Examples

Success response

JSON format

{
  "RequestId": "04F0F334-1335-436C-A1D7-6C044FE73368\n",
  "ConfigId": 352816096987136
}

Error codes

HTTP status code

Error code

Error message

Description

400 MissingParameter The specified ArgName is required for this function. When configuring a specific function, the required parameter is missing.
400 CanNotSetSequence Non-regular configuration, you cannot set Sequence parameters. Sequence parameters is not allowed in global configuration.
400 CacheReserveSiteExceedLimit The number of binding sites of the cache reserve instance exceeds the limit. The number of binding sites of a single cache reserve instance is limited. Please see the document for the limit. The number of sites for which the cache reserve instance bindings exceeds the limit.
400 CompileRuleError Rule compilation failed, please check the rule information passed in to ensure that the rule is written according to the syntax described in the document. Rule compilation failed. Check the incoming rule configuration. For details, see the rule configuration format described in the interface document.
400 SiteConfigLengthExceedLimit The overall configuration size of the site exceeds the limit, and the total size of all functional configurations of the site cannot exceed 512K. The size of the site configuration exceeds the limit, and the total size cannot exceed 512K.
400 ConfigConflicts Configuration conflicts, usually when multiple configurations are configured under the same function of the same site, such as duplicate rule names between multiple configurations. The parameter uniqueness check failed. Check for duplicate parameter values.
400 FunctionConflict The feature configuration conflicts. Sites with version management enabled cannot configure this feature. The currently configured function conflicts with other functions. If you need to configure, delete the conflicting function configurations first.
400 RuleRegexQuotaCheckFailed When configuring rules, rules with regular expressions are not allowed in this plan. Please check the relevant documentation of the plan or upgrade the plan. The current plan does not support the configuration of a rule engine with a regular expression. Please check the plan description and upgrade your plan.
400 NestedRuleQuotaCheckFailed The nesting level of rules allowed by the plan failed to be verified. Please modify the nesting level of rules or upgrade the plan. The number of embedded sub-conditions in the rule exceeds the plan limit. Please check the plan description and upgrade your plan.
400 ArgQuotaCheckFailed The passed-in parameter value failed to verify the validity of the plan. Please check the plan document to obtain the range of parameters that can be configured for the site plan. The current plan does not support the configuration of restricted parameters, please check the input parameters.
400 FunctionQuotaCheckFailed The quota verification for this function fails. It may be that the configuration of this function exceeds the limit of the site plan. Please check the plan introduction document corresponding to this site. The current plan does not support the configuration of restricted functions, please check the plan related function description.
400 ConfExceedLimit The number of function configurations exceeds the limit. Please check the interface document to see the number of configurations that can be supported by a single function. The number of configuration items for the current function has exceeded the upper limit set by the system.
400 ServiceInvokeFailed The call to the internal service failed. The engineer is resolving the problem. Please wait a moment before trying, or contact customer service for details. Failed to call the service. Please try again later or contact customer service for details.
400 SpecifiedVersionReadOnly The specified version number is read-only and cannot be modified. The specified version number is read-only and cannot be modified.
400 VersionNotValid The site does not have version management enabled, or the version number passed in does not exist. The site does not have version management enabled, or the version number passed in does not exist.
400 InternalException Failed to call the service. Try again later or contact technical support. Failed to call the service. Try again later or contact technical support.
400 InvalidParameter.ArgName Invalid ArgName. Check your website configuration parameters and make sure that they match the supported features and parameter names listed in the official documentation. Invalid ArgName. Check your website configuration parameters and make sure that they match the supported features and parameter names listed in the official documentation.
400 InvalidParameter.ArgValue Invalid parameter value. Check whether the value format and length meet the requirements. Invalid parameter value. Check whether the value format and length meet the requirements.
400 InvalidParameter.Configs Invalid parameter configurations. Check whether your feature configurations are in the valid format and comply with relevant requirements. Invalid parameter configurations. Check whether your feature configurations are in the valid format and comply with relevant requirements.
400 InstanceNotExist The instance does not exist. Check whether the specified instance ID is correct or whether the instance belongs to your account. The instance does not exist. Check whether the specified instance ID is correct or whether the instance belongs to your account.
400 LockFailed The system is handling requests you previously submitted. Try again later. The system is handling requests you previously submitted. Try again later.
400 Instance.NotOnline Your plan is unavailable due to an overdue payment. Complete the payment first. Your plan is unavailable due to an overdue payment. Complete the payment first.
400 IllegalOperation.VersionManagement The version management operation failed because incompatible features or environment settings are configured. Adjust your configurations and try again. The version management operation failed because incompatible features or environment settings are configured. Adjust your configurations and try again.
400 QuotaCheckFailed.VersionManagement Insufficient quota for version management. Contact technical support. Insufficient quota for version management. Contact technical support.
400 FunctionArgError Failed to check the configured function parameters. Failed to check the configured function parameters
404 SiteNotFound The website does not exist or does not belong to you. The website does not exist or does not belong to you.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.