Cache Key を使っているリソースは、Cloudflare API で即座にパージできます。Cloudflare の URL 指定パージ を使う場合は、カスタム Cache Key に含まれるヘッダーとクエリ文字列も含めてください。
現在、Worker が設定したカスタム Cache Key を使う Cache API 経由で保存した URL はパージできません。代わりに、Cache Rules で作成したカスタムキー を使ってください。あるいは、すべてをパージする、タグ指定、ホスト指定、プレフィックス指定でアセットをパージします。
device_type、geo、lang で即座にパージするには、それぞれ CF-Device-Type、CF-IPCountry、accept-language を使います。タグ / ホスト指定のパージ と すべてをパージする は、カスタム Cache Key の影響を受けません。
デバイスタイプに基づく Cache Key の場合、API のパージリクエストに CF-Device-Type ヘッダーを付けてアセットをパージします。有効なヘッダー値は mobile、desktop、tablet です。
ルートページ上のモバイル向けアセットをすべて即座にパージする API リクエストの例を次に示します。
Required API token permissions
At least one of the following token permissions is required:Cache Purge
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/purge_cache" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"files": [
{
"url": "http://my.website.com/",
"headers": {
"CF-Device-Type": "mobile"
}
}
]
}'所在地に基づく Cache Key のリソースを即座にパージするには、2 文字の国コードを指定します。次の例ではスペインを使っています。
Required API token permissions
At least one of the following token permissions is required:Cache Purge
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/purge_cache" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"files": [
{
"url": "http://my.website.com/",
"headers": {
"CF-IPCountry": "ES"
}
}
]
}'言語に基づく Cache Key の場合、accept-language ヘッダーを付けてアセットをパージします。中国語(中国)のアセットをすべて即座にパージする API リクエストの例を次に示します。
Required API token permissions
At least one of the following token permissions is required:Cache Purge
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/purge_cache" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"files": [
{
"url": "http://my.website.com/",
"headers": {
"accept-language": "zh-CN"
}
}
]
}'