Skip to content

Instantly share code, notes, and snippets.

@goldsmith
Created August 15, 2014 22:06
Show Gist options
  • Save goldsmith/85de1956e34ed93aec32 to your computer and use it in GitHub Desktop.
Save goldsmith/85de1956e34ed93aec32 to your computer and use it in GitHub Desktop.
PurgeCDN Grunt task
grunt.registerTask('purgecdn', 'Purge MaxCDN pull zone', function() {
var done = this.async();
grunt.config.requires('maxcdn');
var maxcdn = grunt.config('maxcdn');
var api = new MaxCDN(
maxcdn.companyAlias, maxcdn.consumerKey, maxcdn.consumerSecret
);
grunt.log.writeln('purging cache for Pull Zone #' + maxcdn.pullZoneId + '...');
api.del('zones/pull.json/' + maxcdn.pullZoneId + '/cache', function callback(err, response) {
if (err) {
grunt.log.error(JSON.parse(err.data).error.message);
done(false);
return;
}
grunt.log.writeln('successfully purged!');
done();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment