Purge cache key resources

Last updated Apr 16, 2026 Instantly purge resources that use Cache Keys via the Cloudflare API. If you use Cloudflare's Purge by URL, include the headers and query strings that are in your custom Cache Key.

Currently, it is not possible to purge a URL stored through Cache API that uses a custom cache key set by a Worker. Instead, use a custom key created by Cache Rules. Alternatively, purge your assets using purge everything, purge by tag, purge by host or purge by prefix.

To instantly purge by device_type, geo, or lang use CF-Device-Type, CF-IPCountry or accept-language, respectively. Purge by Tag / Host and Purge Everything are not impacted by the use of custom Cache Keys.

Purge by device type

For a Cache Key based on device type, purge the asset by passing the CF-Device-Type header with the API purge request (valid headers include mobile, desktop, and tablet).

Refer to the example API request below to instantly purge all mobile assets on the root webpage.

<details>

<summary>

Required API token permissions

</summary>

At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:

  • <code>Cache Purge</code>

</details>

Purge Cached Contentbash

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"
                        }
                }
        ]
    }'

Purge by geo

Instantly purge resources for a location-based Cache Key by specifying the two-letter country code. Spain is used in the example below.

<details>

<summary>

Required API token permissions

</summary>

At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:

  • <code>Cache Purge</code>

</details>

Purge Cached Contentbash

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"
                        }
                }
        ]
    }'

Purge by language

For a Cache Key based on language, purge the asset by passing the accept-language header. Refer to the example API request below to instantly purge all assets in Chinese (PRC).

<details>

<summary>

Required API token permissions

</summary>

At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:

  • <code>Cache Purge</code>

</details>

Purge Cached Contentbash

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"
                        }
                }
        ]
    }'

Was this helpful?

YesNo

On this page

Purge cache key resources - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/cache/how-to/purge-cache/purge-cache-key/#page","headline":"Purge cache key resources","description":"Purge cached resources by custom cache key.","url":"https://developers.cloudflare.com/cache/how-to/purge-cache/purge-cache-key/","inLanguage":"en","image":"https://developers.cloudflare.com/cache/how-to/purge-cache/purge-cache-key/og.png?v=685fcb474aeca62a","dateModified":"2026-04-16","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["Geolocation"]}


description: Purge all cached content for your entire zone. title: ​Purge everything image: https://developers.cloudflare.com/cache/how-to/purge-cache/purge-everything/og.png?v=566d209c751d82e0


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/cache/llms.txt
Use this file to discover all available pages before exploring further.