Cache

cache

Methods

Purge Cached Content -> Envelope<{ id }>
post/zones/{zone_id}/purge_cache

Purge All Cached Content

Removes ALL files from Cloudflare's cache. All tiers can purge everything.

{"purge_everything": true}

Purge Cached Content by URL

Granularly removes one or more files from Cloudflare's cache by specifying URLs. All tiers can purge by URL.

To purge files with custom cache keys, include the headers used to compute the cache key as in the example. If you have a device type or geo in your cache key, you will need to include the CF-Device-Type or CF-IPCountry headers. If you have lang in your cache key, you will need to include the Accept-Language header.

NB: When including the Origin header, be sure to include the scheme and hostname. The port number can be omitted if it is the default port (80 for http, 443 for https), but must be included otherwise.

NB: For Zones on Free/Pro/Business plan, you may purge up to 30 URLs in one API call. For Zones on Enterprise plan, you may purge up to 500 URLs in one API call.

Single file purge example with files:

{"files": ["http://www.example.com/css/styles.css", "http://www.example.com/js/index.js"]}

Single file purge example with url and header pairs:

{"files": [{url: "http://www.example.com/cat_picture.jpg", headers: { "CF-IPCountry": "US", "CF-Device-Type": "desktop", "Accept-Language": "zh-CN" }}, {url: "http://www.example.com/dog_picture.jpg", headers: { "CF-IPCountry": "EU", "CF-Device-Type": "mobile", "Accept-Language": "en-US" }}]}

Purge Cached Content by Tag, Host or Prefix

Granularly removes one or more files from Cloudflare's cache either by specifying the host, the associated Cache-Tag, or a Prefix. Only Enterprise customers are permitted to purge by Tag, Host or Prefix.

NB: Cache-Tag, host, and prefix purging each have a rate limit of 30,000 purge API calls in every 24 hour period. You may purge up to 30 tags, hosts, or prefixes in one API call. This rate limit can be raised for customers who need to purge at higher volume.

Flex purge with tags:

{"tags": ["a-cache-tag", "another-cache-tag"]}

Flex purge with hosts:

{"hosts": ["www.example.com", "images.example.com"]}

Flex purge with prefixes:

{"prefixes": ["www.example.com/foo", "images.example.com/bar/baz"]}
Cache

Cache Reserve

cache.cache_reserve

Methods

Start Cache Reserve Clear -> Envelope<{ id, modified_on, start_ts, 2 more... }>
post/zones/{zone_id}/cache/cache_reserve_clear

You can use Cache Reserve Clear to clear your Cache Reserve, but you must first disable Cache Reserve. In most cases, this will be accomplished within 24 hours. You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind that you cannot undo or cancel this operation.

Change Cache Reserve Setting -> Envelope<{ id, modified_on, value }>
patch/zones/{zone_id}/cache/cache_reserve

Increase cache lifetimes by automatically storing all cacheable files into Cloudflare's persistent object storage buckets. Requires Cache Reserve subscription. Note: using Tiered Cache with Cache Reserve is highly recommended to reduce Reserve operations costs. See the developer docs for more information.

Get Cache Reserve Setting -> Envelope<{ id, modified_on, value }>
get/zones/{zone_id}/cache/cache_reserve

Increase cache lifetimes by automatically storing all cacheable files into Cloudflare's persistent object storage buckets. Requires Cache Reserve subscription. Note: using Tiered Cache with Cache Reserve is highly recommended to reduce Reserve operations costs. See the developer docs for more information.

Get Cache Reserve Clear -> Envelope<{ id, modified_on, start_ts, 2 more... }>
get/zones/{zone_id}/cache/cache_reserve_clear

You can use Cache Reserve Clear to clear your Cache Reserve, but you must first disable Cache Reserve. In most cases, this will be accomplished within 24 hours. You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind that you cannot undo or cancel this operation.

Domain types

CacheReserve = "cache_reserve"
CacheReserveClear = "cache_reserve_clear"
State = "In-progress" | "Completed"
Cache

Regional Tiered Cache

cache.regional_tiered_cache

Methods

Change Regional Tiered Cache Setting -> Envelope<{ id, modified_on, value }>
patch/zones/{zone_id}/cache/regional_tiered_cache

Instructs Cloudflare to check a regional hub data center on the way to your upper tier. This can help improve performance for smart and custom tiered cache topologies.

Get Regional Tiered Cache Setting -> Envelope<{ id, modified_on, value }>
get/zones/{zone_id}/cache/regional_tiered_cache

Instructs Cloudflare to check a regional hub data center on the way to your upper tier. This can help improve performance for smart and custom tiered cache topologies.

Domain types

RegionalTieredCache = "tc_regional"
Cache

Smart Tiered Cache

cache.smart_tiered_cache

Methods

Delete Smart Tiered Cache Setting -> Envelope<{ id, editable, modified_on, 1 more... }>
delete/zones/{zone_id}/cache/tiered_cache_smart_topology_enable

Remvoves enablement of Smart Tiered Cache

Patch Smart Tiered Cache Setting -> Envelope<{ id, editable, modified_on, 1 more... }>
patch/zones/{zone_id}/cache/tiered_cache_smart_topology_enable

Updates enablement of Tiered Cache

Get Smart Tiered Cache Setting -> Envelope<{ id, editable, modified_on, 1 more... }>
get/zones/{zone_id}/cache/tiered_cache_smart_topology_enable

Get Smart Tiered Cache setting

Cache

Variants

cache.variants

Methods

Delete Variants Setting -> Envelope<>
delete/zones/{zone_id}/cache/variants

Variant support enables caching variants of images with certain file extensions in addition to the original. This only applies when the origin server sends the 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but does not serve the variant requested, the response will not be cached. This will be indicated with BYPASS cache status in the response headers.

Change Variants Setting -> Envelope<{ id, modified_on, value }>
patch/zones/{zone_id}/cache/variants

Variant support enables caching variants of images with certain file extensions in addition to the original. This only applies when the origin server sends the 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but does not serve the variant requested, the response will not be cached. This will be indicated with BYPASS cache status in the response headers.

Get Variants Setting -> Envelope<{ id, modified_on, value }>
get/zones/{zone_id}/cache/variants

Variant support enables caching variants of images with certain file extensions in addition to the original. This only applies when the origin server sends the 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but does not serve the variant requested, the response will not be cached. This will be indicated with BYPASS cache status in the response headers.

Domain types

CacheVariant = { id, modified_on }