Purging and prefetching a CDN content

Introduction

Purge and Prefetch tools of both CDN Static and CDN Static Push services allow you to manage your content in the CDN cache.

You can instantly purge your content from the CDN cache and you can instantly prefetch your origin content to the CDN cache.

Please note that when you purge your content from the CDN cache (or when you add a new content to your origin) then the content is automatically pulled from your origin at the moment when it is requested by your visitor via the corresponding CDN URL.

How to use purge and prefetch tools

There are three tools available.

  • Purge - To purge (flush, remove) content from the CDN cache. It is on a file basis.
  • Purge All - To purge (flush, remove) all content of a CDN service from the CDN cache.
  • Prefetch - To prefetch (prepopulate, push) origin content to the CDN cache, instead of waiting for visitors to request it. It is on a file basis.

Example

To purge a file on the CDN URL http://cdn.mycompany.com/css/style.css first select your CDN service, in this case cdn.mycompany.com and then fill in only path from the CDN URL, in this case /css/style.css.

Example - CDN Static

To prefetch a file on the origin URL http://yourserver.com/css/style.css first select the corresponding CDN service and then fill in only path from the origin URL, in this case /css/style.css.

Example - CDN Static Push

To prefetch a file /public/css/style.css on your CDN storage first select the corresponding CDN service and then fill only path relative to the /public directory, in this case /css/style.css.

Notes

Please note that all paths have to be absolute, wildcards (e.g., /public/css/*) are not supported.

Usage limits

There are two limits set - on a number of requests to our CDN platform and on a number of paths in every purge or prefetch request. Please refer below for the limits and please note that the numbers in brackets "()" represent the limits for free trial accounts.

Number of requests

  • Purge/Purge All - Maximum of 20 (2) requests within 5 minutes.
  • Prefetch - Maximum of 10 (2) requests within 5 minutes.

Number of paths

  • Purge - Maximum of 500 (50) paths in every request.
  • Prefetch
    • CDN Static - Maximum of 500 (50) paths in every request.
    • CDN Static Push - Maximum of 100 (20) paths in every request.

How to check that CDN content has been purged

You can use curl tool and inspect X-Cache (HIT means that the response has been server from the CDN cache, MISS means that the response required pull from origin) and X-Age (for how many seconds is the content stored in the CDN cache) HTTP response headers.

CDN content before purge

curl -I http://12345.r.cdnsun.net/photo.jpeg
X-Age: 1146594
X-Cache: HIT    

The above response HTTP headers say that the response has been served from the CDN cache and that the content is stored in the CDN cache for 1146594 seconds.

CDN content after purge - first request

curl -I http://12345.r.cdnsun.net/photo.jpeg
X-Cache: MISS    

The above response HTTP header says that the response required pull from origin, which means the corresponding CDN content has been purged.

CDN content after purge - subsequent requests

curl -I http://12345.r.cdnsun.net/photo.jpeg
X-Age: 5
X-Cache: HIT    

The above response HTTP headers say that the response has been served from CDN cache and that the content is stored in the CDN cache for 5 seconds.

What next?

Read about purge, purge all and prefetch via our CDN API.

Contact Us

  ______   __   __   _    _   
 /_   _//  \ \\/ // | || | || 
   | ||     \ ` //  | || | || 
  _| ||      | ||   | \\_/ || 
 /__//       |_||    \____//  
 `--`        `-`'     `---`