UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

58 lines 3.14 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from 'cloudflare/resource'; import * as CacheReserveAPI from 'cloudflare/resources/cache/cache-reserve'; import * as RegionalTieredCacheAPI from 'cloudflare/resources/cache/regional-tiered-cache'; import * as SmartTieredCacheAPI from 'cloudflare/resources/cache/smart-tiered-cache'; import * as VariantsAPI from 'cloudflare/resources/cache/variants'; export class Cache extends APIResource { constructor() { super(...arguments); this.cacheReserve = new CacheReserveAPI.CacheReserveResource(this._client); this.smartTieredCache = new SmartTieredCacheAPI.SmartTieredCache(this._client); this.variants = new VariantsAPI.Variants(this._client); this.regionalTieredCache = new RegionalTieredCacheAPI.RegionalTieredCacheResource(this._client); } /** * ### Purge All Cached Content * * Removes ALL files from Cloudflare's cache. All tiers can purge everything. * * ### 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. * * ### 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. */ purge(params, options) { const { zone_id, ...body } = params; return this._client.post(`/zones/${zone_id}/purge_cache`, { body, ...options })._thenUnwrap((obj) => obj.result); } } (function (Cache) { Cache.CacheReserveResource = CacheReserveAPI.CacheReserveResource; Cache.SmartTieredCache = SmartTieredCacheAPI.SmartTieredCache; Cache.Variants = VariantsAPI.Variants; Cache.RegionalTieredCacheResource = RegionalTieredCacheAPI.RegionalTieredCacheResource; })(Cache || (Cache = {})); //# sourceMappingURL=cache.mjs.map