
# 查询缓存规则
#### 功能介绍
查询缓存规则。
#### URI
GET /v1.0/cdn/domains/{domain_id}/cache
表1路径参数 
| 参数        | 是否必选 | 参数类型   | 描述                                                               |
|:---|:---|:---|:---|
| domain_id | 是    | String | 加速域名id。 您可以通过查询加速域名接口查询加速域名id。 |
   
表2Query参数 
| 参数                    | 是否必选 | 参数类型   | 描述                                                                                                                                                              |
|:---|:---|:---|:---|
| enterprise_project_id | 否    | String | 当用户开启企业项目功能时，该参数生效，表示查询资源所属项目，"all"表示所有项目。注意：当使用子账号调用接口时，该参数必传。 您可以通过调用企业项目管理服务（EPS）的查询企业项目列表接口（ListEnterpriseProject）查询企业项目id。 |
   
#### 请求参数
表3请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                       |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | 用户Token。 通过调用IAM服务获取用户Token接口获取（响应消息头中X-Subject-Token的值）。 |
   
#### 响应参数
**状态码：200**
表4响应Body参数 
| 参数           | 参数类型                                                        | 描述    |
|:---|:---|:---|
| cache_config | [CacheConfig] object | 缓存配置。 |
   
 表5CacheConfig 
| 参数                   | 参数类型                                                                  | 描述                           |
|:---|:---|:---|
| ignore_url_parameter | Boolean                                                               | 是否忽略url中的参数。                 |
| follow_origin        | Boolean                                                               | 缓存规则是否遵循源站。                  |
| compress             | [CompressResponse] object | GZIP压缩.                      |
| rules                | Array of [Rules] objects             | 缓存规则，将覆盖之前的规则配置。规则为空重置为默认规则。 |
   
 表6CompressResponse 
| 参数              | 参数类型                                                                      | 描述               |
|:---|:---|:---|
| compress_switch | Integer                                                                   | GZIP压缩开关。0关闭。1打开 |
| compress_rules  | Array of [CompressRules] objects | GZIP压缩规则         |
   
 表7CompressRules 
| 参数                 | 参数类型   | 描述                                            |
|:---|:---|:---|
| compress_type      | String | GZIP压缩类型（目前只支持 gzip）                          |
| compress_file_type | String | GZIP压缩文件类型（文件后缀竖线分隔，如：.js\|.html\|.css\|.xml） |
   
 表8Rules 
| 参数        | 参数类型    | 描述                                                                                                                                                                                                                                                                                                                                                                                                  |
|:---|:---|:---|
| rule_type | Integer | 0：全部类型，表示匹配所有文件，默认值。 1：文件类型，表示按文件后缀匹配。 2：文件夹类型，表示按目录匹配。 3：文件全路径类型，表示按文件全路径匹配，5：缓存首页。                                                                                                                                                                                                                                                                                                                |
| content   | String  | 缓存匹配设置。 当rule_type为0时，为空。 当rule_type为1时，为文件后缀，输入首字符为"."，以";"进行分隔，如.jpg;.zip;.exe，并且输入的文件名后缀总数不超过20个。 当rule_type为2时，为目录，输入要求以"/"作为首字符，以";"进行分隔，如/test/folder01;/test/folder02，并且输入的目录路径总数不超过20个。 当rule_type为3时，为全路径，输入要求以"/"作为首字符，支持匹配指定目录下的具体文件，或者带通配符"\*"的文件，如/test/index.html或/test/\*.jpg。 |
| ttl       | Integer | 缓存时间。最大支持365天。                                                                                                                                                                                                                                                                                                                                                                                      |
| ttl_type  | Integer | 缓存时间单位。1：秒；2：分；3：小时；4：天。                                                                                                                                                                                                                                                                                                                                                                            |
| priority  | Integer | 此条配置的优先级, 默认值1，数值越大，优先级越高。取值范围为1-100，优先级不能相同。                                                                                                                                                                                                                                                                                                                                                       |
   
#### 请求示例
```
GET https://cdn.myhuaweicloud.com/v1.0/cdn/domains/ff8080**********************d71/cache?enterprise_project_id=0
```
#### 响应示例
**状态码：200**
OK
```
{
  "cache_config" : {
    "rules" : [ {
      "rule_type" : 1,
      "content" : ".jpg;.png",
      "ttl" : 30,
      "ttl_type" : 3,
      "priority" : 1
    }, {
      "rule_type" : 0,
      "content" : "",
      "ttl" : 600,
      "ttl_type" : 1,
      "priority" : 1
    } ],
    "ignore_url_parameter" : false,
    "follow_origin" : false,
    "compress" : {
      "compress_switch" : 1,
      "compress_rules" : [ {
        "compress_type" : "gzip",
        "compress_file_type" : ".js|.html|.css|.xml|.json|.shtml|.htm"
      } ]
    }
  }
}
```
#### 状态码
| 状态码 | 描述 |
|:---|:---|
| 200 | OK |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-cdn/ErrorCode.html)。
