应用 - 网络
清除缓存
清除应用在 Edge 上的全局缓存。速率限制为每 60 秒 1 个请求。
POST
/
v2
/
apps
/
{app_id}
/
network
/
purge_cache
清除缓存
curl --request POST \
--url https://api.squarecloud.app/v2/apps/{app_id}/network/purge_cache \
--header 'Authorization: <authorization>'import requests
url = "https://api.squarecloud.app/v2/apps/{app_id}/network/purge_cache"
headers = {"Authorization": "<authorization>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: '<authorization>'}};
fetch('https://api.squarecloud.app/v2/apps/{app_id}/network/purge_cache', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.squarecloud.app/v2/apps/{app_id}/network/purge_cache",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.squarecloud.app/v2/apps/{app_id}/network/purge_cache"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.squarecloud.app/v2/apps/{app_id}/network/purge_cache")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.squarecloud.app/v2/apps/{app_id}/network/purge_cache")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"status": "success"
}
清除缓存会移除 Cloudflare 为应用主域名及任何已绑定自定义域名保存的全部缓存响应,强制下一次针对每个 URL 的请求都从应用重新获取最新内容。当你无法等待资源自身的缓存 TTL 过期时,可以在部署了静态资源或此前已被缓存的 API 响应变更后立即使用它。
清除操作本身是异步的:边缘提供商会确认收到请求,但在各边缘节点间的传播并非即时完成。在工作区共享的应用上,调用者需要具备 Maintainer 或 Administrator 角色。要先推送变更后的文件,请参见 提交应用 或 上传应用。
参数
string
必填
应用的 ID。你可以在应用控制面板的 URL 中找到它。
响应
string
指示调用是否成功。成功时为
success,否则为 error。{
"status": "success"
}
⌘I
清除缓存
curl --request POST \
--url https://api.squarecloud.app/v2/apps/{app_id}/network/purge_cache \
--header 'Authorization: <authorization>'import requests
url = "https://api.squarecloud.app/v2/apps/{app_id}/network/purge_cache"
headers = {"Authorization": "<authorization>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: '<authorization>'}};
fetch('https://api.squarecloud.app/v2/apps/{app_id}/network/purge_cache', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.squarecloud.app/v2/apps/{app_id}/network/purge_cache",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.squarecloud.app/v2/apps/{app_id}/network/purge_cache"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.squarecloud.app/v2/apps/{app_id}/network/purge_cache")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.squarecloud.app/v2/apps/{app_id}/network/purge_cache")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"status": "success"
}

