CDN Pro
创建一个预取请求,从您的源站预取内容来预热CDN Pro的缓存。通过内容提前预取,可避免大量请求涌入源站服务器。发起预取之前,必须先将域名对应的加速项目部署到生产环境。
Open API在线调试功能提供可视化界面在线调试API、支持生成代码示例、快速检索查看API文档等能力。前往调试
参数名称 | 类型 | 必填 | 描述 |
---|---|---|---|
name | String | 否 | 取值范围: <= 1000 字符 预取请求的简短描述。 |
fileList | List | 是 | |
url | String | 否 | 取值范围: [ 10 .. 2048 ] 字符 预取的URL。必须以'http'或'https'开头,长度不超过2048个字符。 |
headers | List | 否 | 如果需要在缓存键中加入请求头,可用该字段指定请求头。 |
name | String | 否 | HTTP 头部名称。 |
value | String | 否 | HTTP 头部值。 |
regions | List | 否 | 指定需要预取内容的大洲,以大洲英文全名表示,例如Asia, Europe。未指定时,表示预取内容到所有大洲的服务器。 |
startTime | String | 否 | RFC 3339格式的日期,表示开始预取的时间。必须使用UTC时间,例如'2021-03-06T00:00:00Z'。 |
webhook | String | 否 | 刷新任务完成时要调用的webhook的ID。webhook是指通过“创建webhook接口”创建的回调接口。 |
prefetchLevel | String | 否 | 取值范围: Edge,Parent 默认值: Parent 指定预取的层级。默认只预取内容到CDN Pro父节点服务器,即Parent中间层级。如果需要预取内容到CDN Pro边缘节点服务器,则指定值为Edge。 预取内容到边缘节点意味着将会有较多的源站请求。 |
参数名称 | 类型 | 描述 |
---|---|---|
Location | String | 通过Location响应头返回新建的预取任务的URL。URL中包含预取任务的ID,可使用该ID调用'查询预取任务详情'接口来查看预取任务详情。URL示例:Location: http://open.chinanetcenter.com/cdn/prefetches/5dca2205f9e9cc0001df7b33 |
错误代码(code) | 描述(message) | HTTP状态码 | 语义 |
---|---|---|---|
InvalidPrefetchUrl | The file list shouldn't be empty. | 400 | 文件列表不能为空。 |
NoSuchDomain | The host 'www.example.com' has not been deployed in the 'production' environment. | 400 | 指定的域名如 'www.example.com' 未部署到生产环境。 |
InvalidRegion | Invalid region. Must be a continent name. | 400 | 指定的区域无效。必须以大洲英文名表示。 |
InvalidTime | The start time has to be within 24 hours in the future. | 400 | 开始时间必须在未来24小时内。 |
#!/bin/bash username="example_username" apiKey="example_apiKey" date=`env LANG="en_US.UTF-8" date -u "+%a, %d %b %Y %H:%M:%S GMT"` password=`echo -en "$date" | openssl dgst -sha1 -hmac $apiKey -binary | openssl enc -base64` curl -i --url "https://open.chinanetcenter.com/cdn/prefetches" \ -X "POST" \ -u "$username:$password" \ -H "Date: $date" \ -H "Accept: application/json" \ -d '{"name": "my new prefetch request", "fileList": [{"url": "http://example.com"}]}'
{ "code": "InvalidPrefetchUrl", "message": "The file list shouldn't be empty." }