Purge multiple files at once #5

kamui opened this Issue Mar 7, 2013 · 9 comments

3 participants


The purge cache endpoint takes a single param called file. Does this mean I have to do a request per file I want to purge? Does it take wildcards, regexp, or an array?


Hey @kamui unfortunately we do not support wildcards or regex at this time. We are working with nginx to enhance the cache purge module. No ETA.

Arrays yes, but it will purge one file at a time, not in parallel.

@jdorfman jdorfman closed this Mar 7, 2013

Wait the file param can be an JSON array of files?

"file": ["/p/123", "/p/123/"]

This would work?


It should. Here is a sample PHP script (sorry not a ruby guy):


require_once('NetDNA.php'); // https://github.com/netdna/netdnarws-php

$api = new NetDNA("companyalias","key","secret");

$arr_purgefiles = array('/', '/index.html', '/ad1.png', '/ad2.gif');

foreach ($arr_purgefiles as $file) {
  $purge_api_call = $api->delete("/zones/pull.json/{zoneid}/cache?file=$file");
    $purge_json = json_decode($purge_api_call);

    if(array_key_exists("code",$purge_json)) {
        if($purge_json->code == 200 || $purge_json->code == 201) {
            echo "File=[$file] purged \n";


Unfortunately, this doesn't work in the ruby gem:

          500: Invalid signature
        @ /Users/jack/.rvm/gems/ruby-2.0.0-p0@gizmo/gems/netdnarws-0.2.4/lib/netdnarws.rb:73:in `_response_as_json'
          /Users/jack/.rvm/gems/ruby-2.0.0-p0@gizmo/gems/netdnarws-0.2.4/lib/netdnarws.rb:101:in `delete'


NETDNA_API.delete("/zones/pull.json/#{zone_id}/cache", { "file" => ["/p/123", "/p/123/"] })

If I pass in a single file it works fine.


@kamui I will have @dlitvakb fix this for you. Thanks for the feedback.

@jdorfman jdorfman reopened this Mar 7, 2013
@dlitvakb dlitvakb was assigned Mar 7, 2013

@jdorfman what the php code does is call the api for each file in the array, this being individual api calls.

I can hook up an additional method for purging, which handles both a list or individual files, so instead of using the purge endpoint we would have the following:

api.purge '/some/file'


api.purge ['/one/file', '/another/file']

How does that sound?

This would still do single purge calls for each file, but it will be a nicer interface for doing it


@dlitvakb that sounds great. @kamui we will have this out today.




@kamui Gem updated on RubyGems the api has the following usage

# Purge a Single File
api.purge @zone_id, @file_name

# Purge Multiple Files (Sequential)
api.purge @zone_id, @file_list

# Purge Zone Cache
api.purge @zone_id
@jdorfman jdorfman closed this Mar 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment