Purge cache key resources
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.
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.
Instantly purge resources for a location-based Cache Key by specifying the two-letter country code. Spain is used in the example below.
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).