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
| Parameter | Type | Required | Description |
|---|---|---|---|
| serviceId | Integer | Mandatory | Service ID. |
| policyId | Integer | Mandatory | Policy ID number for cache control. |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| policyName | String | Mandatory | Policy name for cache control. |
| matchUrlPath | Object | Mandatory | URL path matching configuration that determines which requests the rule applies to. See Match Url Path for details. |
| priority | Integer | Mandatory | Priority weight for the rule. Rules with a higher weight take precedence. The weight must be non-zero. |
| matchQueryString | Object | Optional | Query-string matching configuration used to refine which requests the rule applies to. See Match Query String for details. |
| ttl | Long | Optional | The cache TTL for contents to be cached on edge server in seconds. |
| refererAcl | Object | Optional | Configure resource references by creating a domain list and selecting a configuration type (e.g.,whitelist,blacklist) to control whether a domain has permission to access the resource,thereby ensuring resource security. see Referer Acl for details |
| originAcl | Object | Optional | Configure origins by creating a domain list and selecting a configuration type (e.g.,whitelist,blacklist) to control whether a domain has permission to access data from origin,thereby ensuring resource security. see Origin Acl for details |
| ignoreClientNoCache | Boolean | Optional | True or false to ignore no-cache header(s) sent by the client. Default is false. |
| ignoreOriginNoCache | Boolean | Optional | True or false to ignore no-cache header(s) sent by the origin server. Default is false. |
| ignoreQueryString | Boolean | Optional | True or false to ignore any URL query string when caching contents. Default is false. |
| enableXCache | Boolean | Optional | When enabled all responses from the edge have X-Cache header with values like "HIT from da01.xy01.swiftserve.com", showing whether the response was served from the cache (at least partially) or not. Default is false. |
| noCache | Boolean | Optional | Do not cache the content even if the origin presents it as cacheable. Default is false. |
| autoGzip | Boolean | Optional | automatic gzipping on the CDN side. Default is false. |
| responseHeaders | Array | Optional | List of response header configuration. See Response Headers for details. |
| varyMIMEs | String[] | Optional | Configures so-called "vary for images" feature.Contains a list of mime types, preferred for objects matched by the policy. |
| enabled | Boolean | Optional | Flag defining if policy is active or no. default: true. |
Object: Match Url Path
| Parameter | Type | Required | Description |
|---|---|---|---|
| operator | String | Mandatory | Defines how to match the field. Supported values:prefix,regex,equals,suffix. |
| patterns | String[] | Mandatory | List of patterns matching the URL path string. |
Object: Match Query String
| Parameter | Type | Required | Description |
|---|---|---|---|
| operator | String | Mandatory | Defines how to match the field. Supported values:prefix,regex,equals,suffix. |
| patterns | String[] | Mandatory | List of patterns matching the URL query string. |
Object: Referer/Origin Acl
| Parameter | Type | Required | Description |
|---|---|---|---|
| aclType | String | Mandatory | Types of blacklists and whitelists |
| domainList | String[] | Mandatory | List of domain. |
Object: Response Headers
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | String | Mandatory | Response Header Name. |
| operationType | String | Mandatory | Operation type of response header policy, could be "add" or "replace" or "delete" |
| value | String | Optional | Response Header Value. |
Status Codes, Error Codes and Error Messages
| Status Code | Error Code | Error Message |
|---|---|---|
| 400 | Request.BadRequest | Bad request. |
| 400 | InvalidCustomer.IdEmpty | Customer id can be empty or invalid. |
| 400 | InvalidService.IdIncorrect | Service id is empty or invalid. |
| 400 | ServiceId.IdPermission | ServiceId can not be found or unknown. |
| 400 | InvalidPolicy.Id | Policy Id is empty or invalid. |
| 400 | Invalid.PolicyName | Policy name is required. |
| 400 | InvalidPolicy.MatchURLIncorrect | The matchUrlPath can not be empty. |
| 400 | InvalidPolicy.Operator | Operator must be one of the following: prefix,regex,equals or suffix. |
| 400 | InvalidPolicy.Patterns | Patterns cannot be empty or invalid. |
| 400 | InvalidPolicy.RefererAcl | Invalid AclType, must be in 'whitelist' or 'blacklist'. |
| 400 | InvalidPolicy.Priority | Priority is required. |
| 400 | InvalidPolicy.AclDomainList | The AclDomainList array and every element in it must not be empty. |
| 400 | InvalidPolicy.AclDomainType | The AclDomainList cannot be start with '-' |
| 400 | InvalidPolicy.RefererAcl | Invalid AclType, must be in 'whitelist' or 'blacklist'. |
| 400 | InvalidService.VaryMiME | VaryMiME cannot be empty. |
| 400 | InvalidPolicy.ResponseHeader | Response header 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