Skip to main content

Edit Cache Control

This API is used to edit cache control for website acceleration service.

Request

Request-Line

PUT /cdn/v1.0/services/{serviceId}/cacheControl/{policyId} HTTP/1.1

Request Parameters

Path Parameters

ParameterTypeRequiredDescription
serviceIdIntegerMandatoryThe unique identifier for the service for which the cache control policy will be updated.
policyIdIntegerMandatoryThe unique identifier of the cache control policy to be updated.

Body Parameters

ParameterTypeRequiredDescription
policyNameStringMandatoryPolicy name for the cache control configuration.
matchUrlPathObjectMandatoryURL path matching configuration that determines which requests the rule applies to. See Match Url Path for details.
matchQueryStringObjectOptionalQuery-string matching configuration used to refine which requests the rule applies to. See Match Query String for details.
priorityIntegerMandatoryPriority weight for the rule. Rules with a higher weight take precedence. The weight must be a positive integer (greater than zero).
ttlLongOptionalCache TTL (time-to-live) in seconds for content stored on the edge servers.
refererAclObjectOptionalAccess control based on the Referer header. Defines a domain list and an allow/deny policy to control which referer domains can access the resource. See Referer Acl for details.
originAclObjectOptionalAccess control based on the requesting origin. Defines a domain list and an allow/deny policy to control which referer domains can access the resource. See Origin Acl for details.
ignoreClientNoCacheBooleanOptionalWhen true, ignores no-cache headers sent by the client. Default is false.
ignoreOriginNoCacheBooleanOptionalWhen true, ignores no-cache headers sent by the origin server. Default is false.
ignoreQueryStringBooleanOptionalWhen true, ignores URL query strings when caching content. Default is false.
enableXCacheBooleanOptionalWhen enabled, responses from edge servers include an X-Cache header indicating whether the response was served from cache (e.g., HIT or MISS). Default is false.
noCacheBooleanOptionalWhen true, content is not cached even if the origin indicates it is cacheable. Default is false.
autoGzipDisableBooleanMandatoryDisable automatic Gzip compresstion on the CDN edge. Default is false.
responseHeadersArrayOptionalList of response header configurations. See Response Headers for details.
varyMIMEsArrayOptionalEnables the "vary for images" feature. A list of MIME types (e.g., image/webp, image/jpeg) that should be preferred for objects matched by this policy.
enabledBooleanOptionalWhether the policy is active. Default is true.
Object: Match Url Path
ParameterTypeRequiredDescription
operatorStringMandatoryDefines how to match the field. Supported values: prefix, regex, equals, suffix.
patternsArrayMandatoryList of patterns matching the URL path string.
Object: Match Query String
ParameterTypeRequiredDescription
operatorStringMandatoryDefines how to match the field. Supported values: prefix, regex, equals, suffix.
patternsArrayMandatoryList of patterns matching the URL query string.
Object: Referer/Origin Acl
ParameterTypeRequiredDescription
aclTypeStringMandatoryAccess control type. Support values: whitelist or blacklist.
domainListArrayMandatoryList of domain names to be allowed or blocked.
Object: Response Headers
ParameterTypeRequiredDescription
nameStringMandatoryResponse header name.
operationTypeStringMandatoryOperation to perform on the response header. Supported values: add, replace or delete.
valueStringOptionalResponse header value. Required when operationType is add or replace.

Response

Response Body

ParameterTypeDescription
policyIdIntegerPolicy ID number for cache control.
policyNameStringPolicy name for the cache control configuration.
matchUrlPathObjectURL path matching configuration that determines which requests the rule applies to. See Match Url Path for details.
matchQueryStringObjectQuery-string matching configuration used to refine which requests the rule applies to. See Match Query String for details.
priorityIntegerPriority weight for the rule. Rules with a higher weight take precedence. The weight must be a positive integer (greater than zero).
ttlLongCache TTL (time-to-live) in seconds for content stored on the edge servers.
refererAclObjectAccess control based on the Referer header. Defines a domain list and an allow/deny policy to control which referer domains can access the resource. See Referer Acl for details.
originAclObjectAccess control based on the requesting origin. Defines a domain list and an allow/deny policy to control which referer domains can access the resource. See Origin Acl for details.
ignoreClientNoCacheBooleanWhen true, ignores no-cache headers sent by the client. Default is false.
ignoreOriginNoCacheBooleanWhen true, ignores no-cache headers sent by the origin server. Default is false.
ignoreQueryStringBooleanWhen true, ignores URL query strings when caching content. Default is false.
enableXCacheBooleanWhen enabled, responses from edge servers include an X-Cache header indicating whether the response was served from cache (e.g., HIT or MISS). Default is false.
noCacheBooleanWhen true, content is not cached even if the origin indicates it is cacheable. Default is false.
autoGzipDisableBooleanDisable automatic Gzip compresstion on the CDN edge. Default is false.
responseHeadersArrayList of response header configurations. See Response Headers for details.
varyMIMEsArrayEnables the "vary for images" feature. A list of MIME types (e.g., image/webp, image/jpeg) that should be preferred for objects matched by this policy.
enabledBooleanWhether the policy is active. Default is true.

Status Codes, Error Codes and Error Messages

Status CodeError CodeError Message
400Request.BadRequestBad request.
400InvalidCustomer.IdEmptyCustomer ID cannot be empty or invalid.
400InvalidService.IdIncorrectService ID is empty or invalid.
400InvalidService.IdPermissionService ID cannot be found or unknown.
400InvalidPolicy.IdPolicy ID is empty or invalid.
400Invalid.PolicyNamePolicy name is required.
400InvalidPolicy.MatchURLIncorrectThe matchUrlPath cannot be empty.
400InvalidPolicy.OperatorOperator must be one of the following values: prefix, regex, equals or suffix.
400InvalidPolicy.PatternsPatterns cannot be empty or invalid.
400InvalidPolicy.RefererAclInvalid AclType. must be whitelist or blacklist.
400InvalidPolicy.AclDomainListDomainList cannot be empty and must not contain empty values.
400InvalidPolicy.AclDomainTypeDomainList elements cannot start with '-'
400InvalidPolicy.PriorityPriority is required and must be a positive integer.
400InvalidService.VaryMiMEVaryMIMEs cannot be empty.
400InvalidPolicy.ResponseHeaderResponseHeaders cannot be empty or invalid.

Examples

Edit Cache Control

Request

PUT /cdn/v1.0/services/228657/cacheControl/261956  HTTP/1.1

{
"policyName":"cacheInfo",
"matchUrlPath":{
"operator":"prefix",
"patterns":["/"]
},
"matchQueryString":{
"operator":"prefix",
"patterns":["/"]
},
"priority":110,
"ttl":60,
"refererAcl":{
"aclType":"blacklist",
"domainList":["www.example1.com"]
},
"ignoreClientNoCache":false,
"ignoreOriginNoCache":false,
"ignoreQueryString":true,
"enableXCache":true,
"noCache":false,
"autoGzipDisable":false
}

Successful Response Body

HTTP/1.1 200