Purging is a command to the CDN to stop serving a file from cache. For instance, by making a purge for /images/screen.png, you instruct the network to invalidate this cached picture on all CDN servers globally. When the purge is finished and a visitor requests the purged file, the network will make a conditional request to the main server. Then the origin server will respond by delivering the newer file versions which edge server will cache and serve to visitors.
Some content delivery networks do not invalidate files – they are just deleted from cache. Only a few CDNs perform both. Regardless of purge, the origin should always deliver objects to the CDN with last-modified header. Without it, CDN wouldn’t be able to make conditional requests, and will fetch the whole object from the origin to reply on user request from an expired object. As the result, cache miss responses will be slow, and extra data will be sent over the wire. Sending of the last-modified header accelerates communication between the origin and CDN.
Every CDN provider has its own purging features:
- Purge type: is the object deleted from cache, or it is invalidated (expires in cache)?
- Purge time: most CDN services do not purge files instantly, but it may take several minutes. For example, networks of Verizon Digital Media Services purge quickly (10-30 seconds), but sometimes purging may be incomplete within 60 seconds – they let users know when the purge has finished.
- Purge assurance: some providers let user know that purging of objects has been finished on all CDN PoPs.
- Purge capabilities (by file, all files, per directory, by extension, tag or key). Not every CDN company has all these capabilities. Verizon supports purging by file extension.
- Purge costs: some provides charge for purging, if you exceed the limit number of purges per month.
Now you know what purging is: update of files in CDN cache servers. This is an important feature that ensures relevance of content and makes up for good user experience.