LeaseWeb logo   API Documentation

API Calls to manage content (Purge)

class purge

Purges content from the CDN using a Regular Expression. See About for details.

NOTE: File removal can take up to 10min.

GET /content/purge/{customerNumber}/{zoneID}/{jobID}
Path arguments:
  • customerNumber (integer) – The Customer Number,
  • zoneID (integer) – The ID of the zone from where to Purge
  • jobID (string) – The jobID to get the status of the Job. See Examples.
Responses:
  • 200 – A JSON encoded response with the Job ID and is status
  • 400 – A bad request was made. Ex: JobID has expired or doesn’t exist
  • 403 – The JobID provided is not associated with the account
  • 500 – Error occurred while trying to process the call
DELETE /content/purge/{customerNumber}/{zoneID}/{Expression}
Path arguments:
  • customerNumber (integer) – The Customer Number,
  • zoneID (integer) – The ID of the zone from where to Purge
  • Expression (string) – Regular Expression to use to remove files. See Examples.
Responses:
  • 200 – A JSON encoded response with the ID associated with this purge job or empty JSON if the resource is not on the system
  • 400 – A bad request was made
  • 403 – The Resource provided is not associated with the authorized account
  • 500 – Error occurred while trying to process the call

About the Regex Matching

The Expression field accepts a limited regex so purge of multiple files is allowed. The expression is limited because it only accepts the following characters:

* . ? $ +

So for example, no grouping is allowed.

The purge algorithm will use the expression passed and match it agains the full content of the given zone and delete all content that it matches.

We use internally a search matching algorithm. This means if a expression is set as simple as jpg instead of .*jpg all content that contains jpg. An example of a wrong and corrent expression for deleting files ending in jpg:

WRONG
expression: 'jpg'
why: It matches all content that contains the 'jpg' in it (the same as *jpg*)
matches:'my_file.jpg', 'folder_with_jpg_and_gif/my_image.gif', 'jpgs_are_not_here/', etc...

WRONG
expression: '.*jpg'
why: It matches all content who has 'jpg' preceeded by anything
matches: 'my_file.jpg', 'folder_with_jpg_and_gif/my_image.gif', etc...

CORRECT
expression: 'jpg$'
why: It matches all content ending in 'jpg'
matches: 'my_file.jpg'

So setting the expression correctly is essencial to avoid purging uneeded content. The same applies to directory purging, setting the full path of the directory is essential to avoid deleting other files who could share the same name as the directory (Check example 5)

Examples

Lets assume rule 23 has a CNAME: my.zone.com

Example 1, removing all files terminanting in jpg through wildcard use:

DELETE /content/purge/1234567890/23/.*.jpg
Resolves as: my.zone.com/*.jpg

Example 2, removing a single file:

DELETE /content/purge/1234567890/23/this_image.jpg
Resolves as: my.zone.com/this_image.jpg

Example 3, removing a single file in a specific directory:

DELETE /content/purge/1234567890/23/my_dir/another_dir/this_image.jpg
Resolves as: my.zone.com/my_dir/another_dir/this_image.jpg

Example 4, removing all content:

DELETE /content/purge/1234567890/23/.*
Resolves as: my.zone.com/my_directory/*

Example 5, removing all content from a specific directory:

DELETE /content/purge/1234567890/23/my_directory/.*
Resolves as: my.zone.com/my_directory/*

Notes

The response ID is only usefull for tracing. In case of a Purge error, contact us and indicate the ID from the response.

© Copyright 2014, LeaseWeb CDN