Purge cache by cache-tags (Enterprise only)
Cache-tag purging makes multi-file purging easier because you can bulk purge by adding cache-tags to your assets, such as webpages, image files, and more. Note that Tag, Hostname and Prefix purges are only available for Enterprise customers.
General workflow for cache-tags
- Add tags to the
Cache-TagHTTP response header from your origin web server for your web content, such as pages, static assets, etc. - Ensure your web traffic is proxied through Cloudflare.
- Cloudflare associates the tags in the
Cache-TagHTTP header with the content being cached. - Use specific cache-tags to purge your Cloudflare CDN cache of all content containing that cache-tag from your dashboard or using our API.
- Cloudflare forces a cache miss on content with the purged cache-tag.
Add Cache-Tag HTTP response headers
You add cache-tags to your web content in Cache-Tag HTTP response headers to allow the client and server to pass additional information in requests or responses. HTTP headers consist of a specific case-insensitive name followed by a colon : and the valid value, for example, Cache-Tag:tag1,tag2,tag3. Use commas to separate the tags when you want to use multiple cache-tags.
When your content reaches our edge network, Cloudflare:
- Removes the
Cache-TagHTTP header before sending the response to your website visitor. Your end users never seeCache-TagHTTP headers on your Cloudflare-enabled website. - Removes whitespaces from the header and any before and after cache-tag names:
tag1,tag2andtag1,tag2are considered the same. - Removes all repeated and trailing commas before applying cache-tags:
tag1,,,tag2andtag1,tag2are considered the same.
A few things to remember
- A single HTTP response can have more than one
Cache-TagHTTP header field. - The minimum length of a cache-tag is one byte.
- Individual tags do not have a maximum length, but the aggregate
Cache-TagHTTP header cannot exceed 16 KB after the header field name, which is approximately 1,000 unique tags. Length includes whitespace and commas but does not include the header field name. - For cache purges, the maximum length of a cache-tag in an API call is 1,024 characters.
- The
Cache-TagHTTP header must only contain UTF-8 encoded characters. - Spaces are not allowed in cache-tags.
- Case does not matter. For example,
Tag1andtag1are considered the same.
Purge using cache-tags
- Log in to your Cloudflare dashboard, and select your account and domain.
- Select Caching > Configuration.
- Under Purge Cache, select Custom Purge. The Custom Purge window appears.
- Under Purge by, select Tag.
- In the text box, enter your tags to use to purge the cached resources. To purge multiple cache-tagged resources, separate each tag with a comma or have one tag per line.
- Select Purge.