API中心

修改压缩响应配置

更新时间:2025-08-14 11:27:33

通过接口自助实现压缩响应功能

  • 限制说明:·在中国 加速域名必须已备案完成。 · 加速域名必须不包含如下信息:出售药物和管制刀具类,含有不法言论、信息。 · 视频类加速域名必须有视听许可证;博客论坛或社区类加速域名必须有BBS专项审批资质。 · 接口请求和返回结果接受xml和json格式。
  • 单用户调用频率:300/5min
  • 适用产品:静态加速、动态加速、流媒体点播、互动直播
API鉴权说明详见:API鉴权概览

请求参数

Path 参数

参数名称描述
domain-nameString

需要查询配置的域名或域名id

Body 参数

参数名称描述
*compression-settingsObject

压缩响应功能配置 1.需要设置压缩响应配置时,此项必填 2.为空<compression-settings/>时清空压缩响应配置

compression-enabledString

开启压缩响应功能:允许值为true和false

br-typesString

是否使用br压缩:允许值为true和false

specify-url-patternString

指定URI

custom-file-typesList

自定义文件类型:在指定文件类型外根据自身需求,填写适当的可识别文件类型。可以搭配uri-file-types使用。如果uri-file-types也有配置,实际生效的文件类型是两个入参的总和

file-typesList

MIME类型配置需要压缩的文件类型,默认只对'text'文件类型压缩,配置为*时压缩任意文件类型

ignore-letter-caseString

是否忽略大小写:允许值为true和false

path-patternString

url匹配模式,支持正则,如果是全部匹配,入参可以配置为:.*

custom-patternString

指定常用类型:允许值为homepage和all

uri-file-typesList

文件类型:指定需要缓存的文件类型。 文件类型包括:gif png bmp jpeg jpg html htm shtml mp3 wma flv mp4 wmv zip exe rar css txt ico js swf 如果需要全部类型,则直接传all。多个以分号隔开,all和具体文件类型不能同时配置。

directoryString

目录

file-type-othersList

指定文件类型开启压缩响应的另一种方式,为空可清空配置

返回参数

Body 参数

参数名称描述
codeString

错误代码,当HTTPStatus不为202时出现,表示当前请求调用的错误类型

httpStatusInteger

httpstatus=202;   表示成功调用新增域名接口,可使用header中的x-cnc-request-id查看当前新增域名的部署情况

x-cnc-request-idString

唯一标示的id,用于查询每次请求的任务 (适用全部接口)

messageString

响应信息,成功时为success

错误码

错误代码(code)描述(message)HTTP状态码语义
NoSuchDomain

The specified domain does not exist.\n\n

404域名资源项不存在\n\n
CustomerNoOwnDomain

customer not own domain name[www.example.com].\n\n

400域名不属于该客户\n\n
ConfigError

The config {0} does not access.\n\n

400某个配置无法访问\n\n
InvalidParameter

example: 1. No domain was specified.2.The {0} is invalid.\n\n

400指定入参格式错误\n

示例

JSON
XML
JSON
请求示例
复制代码 复制成功
#!/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://api.cdnetworks.com/api/config/compresssetting/123344" \
-X "PUT" \
-u "$username:$password" \
-H "Date: $date" \
-H "Accept: application/json" \
-H "Content-Type:application/json" \
-d '
{
"compression-settings":{
"compression-enabled":"true",
"path-pattern":"*",
"ignore-letter-case":"true",
"file-types":[ "image/jpeg", "application/" ],
 "uri-file-types":[ "mp3", "zip" ],
 "custom-file-types":[ "json", "wasm" ],
 "custom-pattern":"homepage",
 "directory":"/directory/",
 "specify-url-pattern":"/abc/.*",
"br-types":"true"
}
}'
返回示例
复制代码 复制成功
HTTP/1.1 202 Accepted
Server: openresty/1.11.2.2
Date: Mon, 27 May 2019 07:15:49 GMT
Content-Type: application/json;charset=utf-8
Content-Length: 31
Connection: keep-alive
App-Name: service_confApi
x-cnc-request-id: 90d3b33c-3931-4436
{
    "message":"success",
    "code":""
}
本篇文档内容对您是否有帮助?
有帮助
我要反馈
提交成功!非常感谢您的反馈,我们会继续努力做到更好!