如果你的站点仍在使用已弃用的 Auto Minify 功能,请通过 API 关闭 Auto Minify。
你需要一个具有以下权限的 API 令牌:
- Zone > Zone Settings > Edit
- Zone > Zone Settings > Read
要检查 zone 的 Auto Minify 状态,请向 /zones/{zone_id}/settings/minify 端点发送 GET 请求。
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/settings/minify" \
--header "Authorization: Bearer <API_TOKEN>"{
"result": {
"id": "minify",
"value": { "css": "off", "html": "off", "js": "off" },
"modified_on": null,
"editable": true
},
"success": true,
"errors": [],
"messages": []
}如果高亮行中的任一值为 "on",则需要将其关闭。
要为你的 zone 关闭 Auto Minify,请向 /zones/{zone_id}/settings/minify 端点发送 PATCH 请求。响应中 success 的值应为 true。
curl --request PATCH \
"https://api.cloudflare.com/client/v4/zones/{zone_id}/settings/minify" \
--header "Authorization: Bearer <API_TOKEN>" \
--header "Content-Type: application/json" \
--data '{ "value": { "css": "off","html": "off","js": "off" } }'{
"result": {
"id": "minify",
"value": { "js": "off", "css": "off", "html": "off" },
"modified_on": "2024-11-15T19:32:20.882640Z",
"editable": true
},
"success": true,
"errors": [],
"messages": []
}