Skip to content

CDN Guide » Purge

Last updated: November 10, 2022

Introduction to Purge

Purging is instructing the CDN to no longer serve a file from cache. By doing a purge for /images/logo.png, you instruct the CDN to invalidate that cached image on all edge servers globally. After the purge has completed and a user requests the purged file, the CDN will send a (conditional) request to your origin. Your origin will then respond by sending the newer version of the file which the CDN will cache and serve to users going forward.

Diagram: CDN Purge

Tip: unrelated to purge, your origin should always sends objects to the CDN with the Last-Modified (or ETag) header. Without one of these headers, the CDN cannot do conditional requests and will always fetch the complete object from origin to satisfy a user request for an expired object, resulting in slow cache miss responses and unnecessary bytes over the wire. Sending the Last-Modified (or ETag) header speeds up communication between CDN and origin.

CDNs and Purge

Some CDNs don't do invalidation but delete the object from cache. A few CDNs can do both (you choose). The table below shows differences between CDNs related to purging: speed, capabilities, assurance and more.

Purge speed
Many CDNs nowadays do the purge (near) instantly but on some CDNs it may take several minutes.

Purge costs
Some CDNs (eg. CloudFront) charge for purging if you go over a certain number of purges per month.

Purge type
Is the object invalidated (expires in cache) or deleted (removed from cache)?

Purge capabilities
Purge per file, purge all files, purge per directory (recursive or not), purge by file type or file extension, purge by tag or key. Do not assume every CDN has all these capabilities.

Purge assurance
When has the purging of objects completed on all CDN POPs? Some CDNs provide a way to know, for every purge request, when the purge was actually completed.

CDN comparison

Yes
Sort of/partially
No
Extra costs
Unknown
CDNSpeedIs purging (near) instant? FreeIs purging free with no limits? TypeInvalidate or delete? CapabilitiesAssuranceCDN provides a way to know when purge completed?
AdvancedHosting More info Delete File, all
BelugaCDN More info Delete File, all, directory (recursive/not)
Bunny CDN More info Invalidate File, all, tag
CacheFly More info Delete File, all, directory
CDN77 More info Delete File, all
CDNetworks Delete File, all, directory (recursive/not), file extension
CDNvideo Delete File, all
ChinaCache More info Delete or Invalidation File, all, directory (recursive/not)
Cloudflare More info Invalidate File, all, header
CloudFront More info Unknown File, all, directory (recursive/not)
EdgeNext More info Invalidate or delete File, all, directory (recursive/not)
Edgio More info Invalidate File, all, directory (recursive/not), file extension
Fastly More info Delete or Invalidate File, all, directory (recursive/not), tags
Gcore More info Delete File, all, directory (recursive/not), file type
Imperva Delete File, all, directory (recursive/not), file extension, tags
Kingsoft Cloud More info Delete File, all, directory
Leaseweb More info Delete File, all
Lumen Unknown File, all
StackPath More info Delete File, all, directory, header
Tata Communications More info Invalidate File, all, directory (recursive/not)
Tencent Cloud More info Invalidate File, all, directory (recursive/not)
CDNs missing in this table? That is because we don't have the relevant info

More info per CDN

AdvancedHosting

AdvancedHosting CDN for Static Content should soon have purging complete withing a few seconds. VideoCDN purging takes a few minutes.

BelugaCDN

BelugaCDN exposes completion times and information on how many assets were invalidated by the purge request via the API with real-time feedback in the UI. They support full regular expressions on purge request paths. More info in the docs.

Bunny CDN

Introducing Tag-Based CDN Cache Purging!

CacheFly

CDN Planets measures real-world purge speed of CacheFly every hour from multiple global locations. View the CacheFly Purge Speed data.

CDN77

CDN77 has a limit of 2000 URLs per purge request and limits the number of purge/prefetch requests to 60 per 5 minutes.

ChinaCache

Average purge time is 3 minutes.

Cloudflare

Cloudflare support articles: How do I purge my cache, How to Purge Cache Using Cache-Tags [Enterprise only].

CDN Planets measures real-world purge speed of Cloudflare every hour from multiple global locations. View the Cloudflare Purge Speed data.

CloudFront

Object invalidations typically take from 10 to 100 seconds to complete. You can check the status of an invalidation by viewing your distribution from the CloudFront console (source)
The first 1,000 invalidation paths that you submit per month are free; you pay for each invalidation path over 1,000 in a month. AWS Documentation: Invalidating Objects (Web Distributions Only).

CDN Planets measures real-world purge speed of CloudFront every hour from multiple global locations. View the CloudFront Purge Speed data.

EdgeNext

Purge by tag/key is in development.

Edgio

  • According to Edgio, purging happens pretty fast (10 - 30 seconds) most of the time, but it happens regularly that purging is not complete within 60 seconds. It's handy they provide a way to know when the purge has completed.
  • Edgio supports purging by file extension, e.g. /dir/*.css

CDN Planets measures real-world purge speed of Edgio every hour from multiple global locations. View the Edgio Purge Speed data.

Fastly

Single object purges and surrogate key purges are completed across the entire global edge cache in around 150ms. Purge-all operations take longer, and are comparable to the time required to deploy a service configuration, around 10-20 seconds.
Fastly's API docs cover all capabilities. To get started you can probably best read the Fastly Core Concepts doc about Purging. Fastly customers may run into the API rate limiting.

Gcore

A request for purge will be formed within one minute. Then it will be sent to the CDN servers. Purging time depends on the number of files/paths and usually does not take longer than 15 minutes
More info in their Purge: purge some or all assets from CDN resource cache article.

CDN Planets measures real-world purge speed of Gcore every hour from multiple global locations. View the Gcore Purge Speed data.

Kingsoft Cloud

The average time is 40s, and the completion rate is 99.97% within 5 minutes. For URL purge request, the daily upper limit is 1000. For directory purge request, the daily upper limit is 100.

Leaseweb

Leaseweb Purge API documentation

StackPath

StackPath states a purge takes place immediately. However, "when StackPath experiences a high load, a purge may take 1 to 2 minutes to complete.". Learn more in the StackPath Help doc at Purge Files from the CDN, including about purge rate limits.

Tata Communications

Tata does not accept purge requests containing internationalized characters like è ó ö À. The solution is to encode the path to the file, like so for example with JavaScript: encodeURI("/images/ståle/1.png"). The result will be "/images/st%C3%A5le/1.png" and Tata purging works with this.
From experience, we know purging happens fast across all POPs almost always. However, it is too bad Tata gives no insight into if and when the purge has happened. The good news is that Tata serves responses with the Age header, e.g. Age: 69714. This tells you the number of seconds the object has been in cache. If you see Age: 0 you know TATA just fetched the object from origin. You can easily check the Age header value with curl. The following command GET fetches an object and prints out the response headers:

curl --compressed -svo /dev/null 'https://cdn.tatacommunications.com/'

Tencent Cloud

The distribution of the purge request across the network takes approximately 5 minutes. Custom purges such as tag, key or header require Tencent DevOps involvement. 10000 files and 100 folder purges are the default daily values which can be adjusted on special request. Each purge request and status is logged. Logs data is available through the console.

More CDN Guides