缓存刷新接口
更新时间:2025-12-11
接口
本接口用于刷新已经缓存的资源,支持批量提交,一次最多提交1000个url刷新请求或100个目录刷新请求。您可以根据您购买的GEO套餐,知晓您24小时之内最多提交url刷新和目录刷新请求的额度。
请求接口
| Method | Path | 说明 |
|---|---|---|
| POST | /v2/geo/cache/purge | 刷新缓存接口 |
请求体
| 参数 | 类型 | 可选 | 说明 |
|---|---|---|---|
| tasks | PurgeTask[] | 必选 | 提交的刷新任务列表详情。 |
| site | String | 必选 | 提交刷新任务的站点。 |
PurgeTask 类型如下:
| 参数 | 类型 | 可选 | 说明 |
|---|---|---|---|
| url | String | 必选 | 表示需要刷新的 url,如果 type 为 directory,必须以 “/” 结尾。 |
| type | String | 可选 | 可选值为 file、directory,默认为 file。 |
响应码
| HTTP Status Code | 说明 |
|---|---|
| 201 | 刷新接口下发成功 |
| 其他错误码 | 额度不足、参数错误、用户操作错误等 |
响应体
| 参数 | 类型 | 说明 |
|---|---|---|
| id | String | 提交刷新任务后生成的 id,可用于查询任务状态。 |
请求示例1: url 刷新
Plain Text
1POST /v2/geo/cache/purge HTTP/1.1
2Host: geo.baidubce.com
3Content-Length: 46
4Authorization: xxx
5Content-Type: application/json;charset=utf-8
6Accept-Encoding: gzip
7
8{
9 "tasks": [
10 {
11 "url": "http://1.test.com/test1.png",
12 "type": "file"
13 },
14 {
15 "url": "http://1.test.com/test2.png",
16 "type": "file"
17 }
18 ],
19 "site": "test.com"
20}
请求示例2: 目录刷新
Plain Text
1POST /v2/geo/cache/purge HTTP/1.1
2Host: geo.baidubce.com
3Content-Length: 46
4Authorization: xxx
5Content-Type: application/json;charset=utf-8
6Accept-Encoding: gzip
7
8{
9 "tasks": [
10 {
11 "url": "http://1.test.com/",
12 "type": "directory"
13 }
14 ],
15 "site": "test.com"
16}
响应示例
Plain Text
1HTTP/1.1 201 OK
2Server: nginx/1.16.1
3Content-Type: application/json; charset=utf-8
4Transfer-Encoding: chunked
5Connection: keep-alive
6
7{
8 "id": "xxx"
9}
评价此篇文章
