设置缓存过期规则
更新时间:2021-01-25
本接口用于更新指定加速域名的缓存策略。此域名必须是本用户的,否则会返回404失败。
Method | Path | 说明 |
---|---|---|
PUT | /v2/dsa/domain/{domain}/config?action=cacheTtl | 修改加速域名文件类型的缓存策略 |
请求体(Request Body)
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
cacheTtl | 必选 | CacheTTL | 缓存规则列表 |
CacheTTL
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
type | 必选 | String | "suffix"表示文件名后缀,"path"表示url中的目录,"origin"表示源站规则,此规则只有一条,只表示出权重即可,value为"-", ttl为 0,"code"表示异常码缓存,如可以配置404缓存100s ,“exactPath”表示路径完全匹配 |
value | 必选 | String | type所指定类型的配置规则 |
weight | 可选 | Int | 权重,0-100的整数,权重越高优先级越高,默认为0,优先级在为code类型下是没有作用的,可以忽略 |
ttl | 必选 | Int | 缓存时间,单位为秒 |
响应码 (Http Status Code)
HTTP Status Code | 说明 |
---|---|
200 | 成功 |
请求示例
Plain Text
1PUT /v2/dsa/domain/myself.baidu.com/config?action=cacheTtl HTTP/1.1
2Host: cdn.baidubce.com
3Content-Length: 145
4Content-Type: text/json;utf-8
5
6{
7 "cacheTTL":
8 [
9 {"type": "suffix", "value": ".jpg", "ttl":36000, "weight": 30},
10 {"type": "suffix", "value": ".mp4", "ttl":36000, "weight": 30},
11 {"type": "path", "value": "/path/to/my/file", "ttl":1800, "weight": 5}
12 ]
13}
响应示例
Plain Text
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN