# Cache ## Purge Cached Content `client.cache.purge(CachePurgeParamsparams, RequestOptionsoptions?): CachePurgeResponse | null` **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. 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. 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"]} ``` ### Availability and limits please refer to [purge cache availability and limits documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/#availability-and-limits). ### Parameters - `CachePurgeParams = CachePurgeFlexPurgeByTags | CachePurgeFlexPurgeByHostnames | CachePurgeFlexPurgeByPrefixes | 3 more` - `CachePurgeParamsBase` - `CachePurgeFlexPurgeByTags extends CachePurgeParamsBase` - `CachePurgeFlexPurgeByHostnames extends CachePurgeParamsBase` - `CachePurgeFlexPurgeByPrefixes extends CachePurgeParamsBase` - `CachePurgeEverything extends CachePurgeParamsBase` - `CachePurgeSingleFile extends CachePurgeParamsBase` - `CachePurgeSingleFileWithURLAndHeaders extends CachePurgeParamsBase` ### Returns - `CachePurgeResponse` - `id: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.cache.purge({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }); console.log(response.id); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "023e105f4ecef8ad9ca31a8372d0c353" } } ``` ## Domain Types ### Cache Purge Response - `CachePurgeResponse` - `id: string` # Cache Reserve ## Get Cache Reserve setting `client.cache.cacheReserve.get(CacheReserveGetParamsparams, RequestOptionsoptions?): CacheReserveGetResponse` **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](https://developers.cloudflare.com/cache/about/cache-reserve) for more information. ### Parameters - `params: CacheReserveGetParams` - `zone_id: string` Identifier. ### Returns - `CacheReserveGetResponse` - `id: CacheReserve` The identifier of the caching setting. - `"cache_reserve"` - `editable: boolean` Whether the setting is editable. - `value: "on" | "off"` Value of the Cache Reserve zone setting. - `"on"` - `"off"` - `modified_on?: string | null` Last time this setting was modified. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const cacheReserve = await client.cache.cacheReserve.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(cacheReserve.id); ``` #### Response ```json { "errors": [], "messages": [], "result": { "editable": true, "id": "cache_reserve", "value": "off" }, "success": true } ``` ## Change Cache Reserve setting `client.cache.cacheReserve.edit(CacheReserveEditParamsparams, RequestOptionsoptions?): CacheReserveEditResponse` **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](https://developers.cloudflare.com/cache/about/cache-reserve) for more information. ### Parameters - `params: CacheReserveEditParams` - `zone_id: string` Path param: Identifier. - `value: "on" | "off"` Body param: Value of the Cache Reserve zone setting. - `"on"` - `"off"` ### Returns - `CacheReserveEditResponse` - `id: CacheReserve` The identifier of the caching setting. - `"cache_reserve"` - `editable: boolean` Whether the setting is editable. - `value: "on" | "off"` Value of the Cache Reserve zone setting. - `"on"` - `"off"` - `modified_on?: string | null` Last time this setting was modified. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.cache.cacheReserve.edit({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', value: 'on', }); console.log(response.id); ``` #### Response ```json { "errors": [], "messages": [], "result": { "editable": true, "id": "cache_reserve", "value": "on" }, "success": true } ``` ## Get Cache Reserve Clear `client.cache.cacheReserve.status(CacheReserveStatusParamsparams, RequestOptionsoptions?): CacheReserveStatusResponse` **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. ### Parameters - `params: CacheReserveStatusParams` - `zone_id: string` Identifier. ### Returns - `CacheReserveStatusResponse` 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. - `id: CacheReserveClear` ID of the zone setting. - `"cache_reserve_clear"` - `start_ts: string` The time that the latest Cache Reserve Clear operation started. - `state: State` The current state of the Cache Reserve Clear operation. - `"In-progress"` - `"Completed"` - `end_ts?: string` The time that the latest Cache Reserve Clear operation completed. - `modified_on?: string | null` Last time this setting was modified. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.cache.cacheReserve.status({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(response.id); ``` #### Response ```json { "errors": [], "messages": [], "result": { "end_ts": "2023-10-02T12:00:00.12345Z", "id": "cache_reserve_clear", "start_ts": "2023-10-02T10:00:00.12345Z", "state": "Completed" }, "success": true } ``` ## Start Cache Reserve Clear `client.cache.cacheReserve.clear(CacheReserveClearParamsparams, RequestOptionsoptions?): CacheReserveClearResponse` **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. ### Parameters - `params: CacheReserveClearParams` - `zone_id: string` Path param: Identifier. - `body: unknown` Body param ### Returns - `CacheReserveClearResponse` 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. - `id: CacheReserveClear` ID of the zone setting. - `"cache_reserve_clear"` - `start_ts: string` The time that the latest Cache Reserve Clear operation started. - `state: State` The current state of the Cache Reserve Clear operation. - `"In-progress"` - `"Completed"` - `end_ts?: string` The time that the latest Cache Reserve Clear operation completed. - `modified_on?: string | null` Last time this setting was modified. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.cache.cacheReserve.clear({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', body: {}, }); console.log(response.id); ``` #### Response ```json { "errors": [], "messages": [], "result": { "id": "cache_reserve_clear", "start_ts": "2023-10-02T10:00:00.12345Z", "state": "In-progress" }, "success": true } ``` ## Domain Types ### Cache Reserve - `CacheReserve = "cache_reserve"` The identifier of the caching setting. - `"cache_reserve"` ### Cache Reserve Clear - `CacheReserveClear = "cache_reserve_clear"` ID of the zone setting. - `"cache_reserve_clear"` ### State - `State = "In-progress" | "Completed"` The current state of the Cache Reserve Clear operation. - `"In-progress"` - `"Completed"` ### Cache Reserve Get Response - `CacheReserveGetResponse` - `id: CacheReserve` The identifier of the caching setting. - `"cache_reserve"` - `editable: boolean` Whether the setting is editable. - `value: "on" | "off"` Value of the Cache Reserve zone setting. - `"on"` - `"off"` - `modified_on?: string | null` Last time this setting was modified. ### Cache Reserve Edit Response - `CacheReserveEditResponse` - `id: CacheReserve` The identifier of the caching setting. - `"cache_reserve"` - `editable: boolean` Whether the setting is editable. - `value: "on" | "off"` Value of the Cache Reserve zone setting. - `"on"` - `"off"` - `modified_on?: string | null` Last time this setting was modified. ### Cache Reserve Status Response - `CacheReserveStatusResponse` 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. - `id: CacheReserveClear` ID of the zone setting. - `"cache_reserve_clear"` - `start_ts: string` The time that the latest Cache Reserve Clear operation started. - `state: State` The current state of the Cache Reserve Clear operation. - `"In-progress"` - `"Completed"` - `end_ts?: string` The time that the latest Cache Reserve Clear operation completed. - `modified_on?: string | null` Last time this setting was modified. ### Cache Reserve Clear Response - `CacheReserveClearResponse` 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. - `id: CacheReserveClear` ID of the zone setting. - `"cache_reserve_clear"` - `start_ts: string` The time that the latest Cache Reserve Clear operation started. - `state: State` The current state of the Cache Reserve Clear operation. - `"In-progress"` - `"Completed"` - `end_ts?: string` The time that the latest Cache Reserve Clear operation completed. - `modified_on?: string | null` Last time this setting was modified. # Smart Tiered Cache ## Get Smart Tiered Cache setting `client.cache.smartTieredCache.get(SmartTieredCacheGetParamsparams, RequestOptionsoptions?): SmartTieredCacheGetResponse` **get** `/zones/{zone_id}/cache/tiered_cache_smart_topology_enable` Smart Tiered Cache dynamically selects the single closest upper tier for each of your website’s origins with no configuration required, using our in-house performance and routing data. Cloudflare collects latency data for each request to an origin, and uses the latency data to determine how well any upper-tier data center is connected with an origin. As a result, Cloudflare can select the data center with the lowest latency to be the upper-tier for an origin. ### Parameters - `params: SmartTieredCacheGetParams` - `zone_id: string` Identifier. ### Returns - `SmartTieredCacheGetResponse` - `id: "tiered_cache_smart_topology_enable"` The identifier of the caching setting. - `"tiered_cache_smart_topology_enable"` - `editable: boolean` Whether the setting is editable. - `value: "on" | "off"` Value of the Smart Tiered Cache zone setting. - `"on"` - `"off"` - `modified_on?: string | null` Last time this setting was modified. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const smartTieredCache = await client.cache.smartTieredCache.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(smartTieredCache.id); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "tiered_cache_smart_topology_enable", "editable": true, "value": "on", "modified_on": "2014-01-01T05:20:00.12345Z" } } ``` ## Patch Smart Tiered Cache setting `client.cache.smartTieredCache.edit(SmartTieredCacheEditParamsparams, RequestOptionsoptions?): SmartTieredCacheEditResponse` **patch** `/zones/{zone_id}/cache/tiered_cache_smart_topology_enable` Smart Tiered Cache dynamically selects the single closest upper tier for each of your website’s origins with no configuration required, using our in-house performance and routing data. Cloudflare collects latency data for each request to an origin, and uses the latency data to determine how well any upper-tier data center is connected with an origin. As a result, Cloudflare can select the data center with the lowest latency to be the upper-tier for an origin. ### Parameters - `params: SmartTieredCacheEditParams` - `zone_id: string` Path param: Identifier. - `value: "on" | "off"` Body param: Enable or disable the Smart Tiered Cache. - `"on"` - `"off"` ### Returns - `SmartTieredCacheEditResponse` - `id: "tiered_cache_smart_topology_enable"` The identifier of the caching setting. - `"tiered_cache_smart_topology_enable"` - `editable: boolean` Whether the setting is editable. - `value: "on" | "off"` Value of the Smart Tiered Cache zone setting. - `"on"` - `"off"` - `modified_on?: string | null` Last time this setting was modified. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.cache.smartTieredCache.edit({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', value: 'on', }); console.log(response.id); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "tiered_cache_smart_topology_enable", "editable": true, "value": "on", "modified_on": "2014-01-01T05:20:00.12345Z" } } ``` ## Delete Smart Tiered Cache setting `client.cache.smartTieredCache.delete(SmartTieredCacheDeleteParamsparams, RequestOptionsoptions?): SmartTieredCacheDeleteResponse` **delete** `/zones/{zone_id}/cache/tiered_cache_smart_topology_enable` Smart Tiered Cache dynamically selects the single closest upper tier for each of your website’s origins with no configuration required, using our in-house performance and routing data. Cloudflare collects latency data for each request to an origin, and uses the latency data to determine how well any upper-tier data center is connected with an origin. As a result, Cloudflare can select the data center with the lowest latency to be the upper-tier for an origin. ### Parameters - `params: SmartTieredCacheDeleteParams` - `zone_id: string` Identifier. ### Returns - `SmartTieredCacheDeleteResponse` - `id: "tiered_cache_smart_topology_enable"` The identifier of the caching setting. - `"tiered_cache_smart_topology_enable"` - `editable: boolean` Whether the setting is editable. - `modified_on?: string | null` Last time this setting was modified. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const smartTieredCache = await client.cache.smartTieredCache.delete({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(smartTieredCache.id); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "tiered_cache_smart_topology_enable", "editable": true, "modified_on": "2014-01-01T05:20:00.12345Z" } } ``` ## Domain Types ### Smart Tiered Cache Get Response - `SmartTieredCacheGetResponse` - `id: "tiered_cache_smart_topology_enable"` The identifier of the caching setting. - `"tiered_cache_smart_topology_enable"` - `editable: boolean` Whether the setting is editable. - `value: "on" | "off"` Value of the Smart Tiered Cache zone setting. - `"on"` - `"off"` - `modified_on?: string | null` Last time this setting was modified. ### Smart Tiered Cache Edit Response - `SmartTieredCacheEditResponse` - `id: "tiered_cache_smart_topology_enable"` The identifier of the caching setting. - `"tiered_cache_smart_topology_enable"` - `editable: boolean` Whether the setting is editable. - `value: "on" | "off"` Value of the Smart Tiered Cache zone setting. - `"on"` - `"off"` - `modified_on?: string | null` Last time this setting was modified. ### Smart Tiered Cache Delete Response - `SmartTieredCacheDeleteResponse` - `id: "tiered_cache_smart_topology_enable"` The identifier of the caching setting. - `"tiered_cache_smart_topology_enable"` - `editable: boolean` Whether the setting is editable. - `modified_on?: string | null` Last time this setting was modified. # Variants ## Get variants setting `client.cache.variants.get(VariantGetParamsparams, RequestOptionsoptions?): VariantGetResponse` **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. ### Parameters - `params: VariantGetParams` - `zone_id: string` Identifier. ### Returns - `VariantGetResponse` - `id: "variants"` The identifier of the caching setting. - `"variants"` - `editable: boolean` Whether the setting is editable. - `value: Value` Value of the zone setting. - `avif?: Array` List of strings with the MIME types of all the variants that should be served for avif. - `bmp?: Array` List of strings with the MIME types of all the variants that should be served for bmp. - `gif?: Array` List of strings with the MIME types of all the variants that should be served for gif. - `jp2?: Array` List of strings with the MIME types of all the variants that should be served for jp2. - `jpeg?: Array` List of strings with the MIME types of all the variants that should be served for jpeg. - `jpg?: Array` List of strings with the MIME types of all the variants that should be served for jpg. - `jpg2?: Array` List of strings with the MIME types of all the variants that should be served for jpg2. - `png?: Array` List of strings with the MIME types of all the variants that should be served for png. - `tif?: Array` List of strings with the MIME types of all the variants that should be served for tif. - `tiff?: Array` List of strings with the MIME types of all the variants that should be served for tiff. - `webp?: Array` List of strings with the MIME types of all the variants that should be served for webp. - `modified_on?: string | null` Last time this setting was modified. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const variant = await client.cache.variants.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }); console.log(variant.id); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "variants", "editable": true, "value": { "avif": [ "image/webp", "image/jpeg" ], "bmp": [ "image/webp", "image/jpeg" ], "gif": [ "image/webp", "image/jpeg" ], "jp2": [ "image/webp", "image/avif" ], "jpeg": [ "image/webp", "image/avif" ], "jpg": [ "image/webp", "image/avif" ], "jpg2": [ "image/webp", "image/avif" ], "png": [ "image/webp", "image/avif" ], "tif": [ "image/webp", "image/avif" ], "tiff": [ "image/webp", "image/avif" ], "webp": [ "image/jpeg", "image/avif" ] }, "modified_on": "2014-01-01T05:20:00.12345Z" } } ``` ## Change variants setting `client.cache.variants.edit(VariantEditParamsparams, RequestOptionsoptions?): VariantEditResponse` **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. ### Parameters - `params: VariantEditParams` - `zone_id: string` Path param: Identifier. - `value: Value` Body param: Value of the zone setting. - `avif?: Array` List of strings with the MIME types of all the variants that should be served for avif. - `bmp?: Array` List of strings with the MIME types of all the variants that should be served for bmp. - `gif?: Array` List of strings with the MIME types of all the variants that should be served for gif. - `jp2?: Array` List of strings with the MIME types of all the variants that should be served for jp2. - `jpeg?: Array` List of strings with the MIME types of all the variants that should be served for jpeg. - `jpg?: Array` List of strings with the MIME types of all the variants that should be served for jpg. - `jpg2?: Array` List of strings with the MIME types of all the variants that should be served for jpg2. - `png?: Array` List of strings with the MIME types of all the variants that should be served for png. - `tif?: Array` List of strings with the MIME types of all the variants that should be served for tif. - `tiff?: Array` List of strings with the MIME types of all the variants that should be served for tiff. - `webp?: Array` List of strings with the MIME types of all the variants that should be served for webp. ### Returns - `VariantEditResponse` - `id: "variants"` The identifier of the caching setting. - `"variants"` - `editable: boolean` Whether the setting is editable. - `value: Value` Value of the zone setting. - `avif?: Array` List of strings with the MIME types of all the variants that should be served for avif. - `bmp?: Array` List of strings with the MIME types of all the variants that should be served for bmp. - `gif?: Array` List of strings with the MIME types of all the variants that should be served for gif. - `jp2?: Array` List of strings with the MIME types of all the variants that should be served for jp2. - `jpeg?: Array` List of strings with the MIME types of all the variants that should be served for jpeg. - `jpg?: Array` List of strings with the MIME types of all the variants that should be served for jpg. - `jpg2?: Array` List of strings with the MIME types of all the variants that should be served for jpg2. - `png?: Array` List of strings with the MIME types of all the variants that should be served for png. - `tif?: Array` List of strings with the MIME types of all the variants that should be served for tif. - `tiff?: Array` List of strings with the MIME types of all the variants that should be served for tiff. - `webp?: Array` List of strings with the MIME types of all the variants that should be served for webp. - `modified_on?: string | null` Last time this setting was modified. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.cache.variants.edit({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', value: {}, }); console.log(response.id); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "variants", "editable": true, "value": { "avif": [ "image/webp", "image/jpeg" ], "bmp": [ "image/webp", "image/jpeg" ], "gif": [ "image/webp", "image/jpeg" ], "jp2": [ "image/webp", "image/avif" ], "jpeg": [ "image/webp", "image/avif" ], "jpg": [ "image/webp", "image/avif" ], "jpg2": [ "image/webp", "image/avif" ], "png": [ "image/webp", "image/avif" ], "tif": [ "image/webp", "image/avif" ], "tiff": [ "image/webp", "image/avif" ], "webp": [ "image/jpeg", "image/avif" ] }, "modified_on": "2014-01-01T05:20:00.12345Z" } } ``` ## Delete variants setting `client.cache.variants.delete(VariantDeleteParamsparams, RequestOptionsoptions?): VariantDeleteResponse` **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. ### Parameters - `params: VariantDeleteParams` - `zone_id: string` Identifier. ### Returns - `VariantDeleteResponse` - `id: "variants"` The identifier of the caching setting. - `"variants"` - `editable: boolean` Whether the setting is editable. - `modified_on?: string | null` Last time this setting was modified. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const variant = await client.cache.variants.delete({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }); console.log(variant.id); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "variants", "editable": true, "modified_on": "2014-01-01T05:20:00.12345Z" } } ``` ## Domain Types ### Cache Variant - `CacheVariant` 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. - `id: "variants"` ID of the zone setting. - `"variants"` - `modified_on?: string | null` Last time this setting was modified. ### Variant Get Response - `VariantGetResponse` - `id: "variants"` The identifier of the caching setting. - `"variants"` - `editable: boolean` Whether the setting is editable. - `value: Value` Value of the zone setting. - `avif?: Array` List of strings with the MIME types of all the variants that should be served for avif. - `bmp?: Array` List of strings with the MIME types of all the variants that should be served for bmp. - `gif?: Array` List of strings with the MIME types of all the variants that should be served for gif. - `jp2?: Array` List of strings with the MIME types of all the variants that should be served for jp2. - `jpeg?: Array` List of strings with the MIME types of all the variants that should be served for jpeg. - `jpg?: Array` List of strings with the MIME types of all the variants that should be served for jpg. - `jpg2?: Array` List of strings with the MIME types of all the variants that should be served for jpg2. - `png?: Array` List of strings with the MIME types of all the variants that should be served for png. - `tif?: Array` List of strings with the MIME types of all the variants that should be served for tif. - `tiff?: Array` List of strings with the MIME types of all the variants that should be served for tiff. - `webp?: Array` List of strings with the MIME types of all the variants that should be served for webp. - `modified_on?: string | null` Last time this setting was modified. ### Variant Edit Response - `VariantEditResponse` - `id: "variants"` The identifier of the caching setting. - `"variants"` - `editable: boolean` Whether the setting is editable. - `value: Value` Value of the zone setting. - `avif?: Array` List of strings with the MIME types of all the variants that should be served for avif. - `bmp?: Array` List of strings with the MIME types of all the variants that should be served for bmp. - `gif?: Array` List of strings with the MIME types of all the variants that should be served for gif. - `jp2?: Array` List of strings with the MIME types of all the variants that should be served for jp2. - `jpeg?: Array` List of strings with the MIME types of all the variants that should be served for jpeg. - `jpg?: Array` List of strings with the MIME types of all the variants that should be served for jpg. - `jpg2?: Array` List of strings with the MIME types of all the variants that should be served for jpg2. - `png?: Array` List of strings with the MIME types of all the variants that should be served for png. - `tif?: Array` List of strings with the MIME types of all the variants that should be served for tif. - `tiff?: Array` List of strings with the MIME types of all the variants that should be served for tiff. - `webp?: Array` List of strings with the MIME types of all the variants that should be served for webp. - `modified_on?: string | null` Last time this setting was modified. ### Variant Delete Response - `VariantDeleteResponse` - `id: "variants"` The identifier of the caching setting. - `"variants"` - `editable: boolean` Whether the setting is editable. - `modified_on?: string | null` Last time this setting was modified. # Regional Tiered Cache ## Get Regional Tiered Cache setting `client.cache.regionalTieredCache.get(RegionalTieredCacheGetParamsparams, RequestOptionsoptions?): RegionalTieredCacheGetResponse` **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. ### Parameters - `params: RegionalTieredCacheGetParams` - `zone_id: string` Identifier. ### Returns - `RegionalTieredCacheGetResponse` - `id: RegionalTieredCache` The identifier of the caching setting. - `"tc_regional"` - `editable: boolean` Whether the setting is editable. - `value: "on" | "off"` Value of the Regional Tiered Cache zone setting. - `"on"` - `"off"` - `modified_on?: string | null` Last time this setting was modified. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const regionalTieredCache = await client.cache.regionalTieredCache.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(regionalTieredCache.id); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "tc_regional", "editable": true, "value": "on", "modified_on": "2014-01-01T05:20:00.12345Z" } } ``` ## Change Regional Tiered Cache setting `client.cache.regionalTieredCache.edit(RegionalTieredCacheEditParamsparams, RequestOptionsoptions?): RegionalTieredCacheEditResponse` **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. ### Parameters - `params: RegionalTieredCacheEditParams` - `zone_id: string` Path param: Identifier. - `value: "on" | "off"` Body param: Value of the Regional Tiered Cache zone setting. - `"on"` - `"off"` ### Returns - `RegionalTieredCacheEditResponse` - `id: RegionalTieredCache` The identifier of the caching setting. - `"tc_regional"` - `editable: boolean` Whether the setting is editable. - `value: "on" | "off"` Value of the Regional Tiered Cache zone setting. - `"on"` - `"off"` - `modified_on?: string | null` Last time this setting was modified. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.cache.regionalTieredCache.edit({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', value: 'on', }); console.log(response.id); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "tc_regional", "editable": true, "value": "on", "modified_on": "2014-01-01T05:20:00.12345Z" } } ``` ## Domain Types ### Regional Tiered Cache - `RegionalTieredCache = "tc_regional"` The identifier of the caching setting. - `"tc_regional"` ### Regional Tiered Cache Get Response - `RegionalTieredCacheGetResponse` - `id: RegionalTieredCache` The identifier of the caching setting. - `"tc_regional"` - `editable: boolean` Whether the setting is editable. - `value: "on" | "off"` Value of the Regional Tiered Cache zone setting. - `"on"` - `"off"` - `modified_on?: string | null` Last time this setting was modified. ### Regional Tiered Cache Edit Response - `RegionalTieredCacheEditResponse` - `id: RegionalTieredCache` The identifier of the caching setting. - `"tc_regional"` - `editable: boolean` Whether the setting is editable. - `value: "on" | "off"` Value of the Regional Tiered Cache zone setting. - `"on"` - `"off"` - `modified_on?: string | null` Last time this setting was modified.