A Grunt plugin to purge cache from Fastly
npm install grunt-fastlyA Grunt plugin to purge cache from Fastly

^1.0.1If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
``shell`
npm install grunt-fastly --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
`js`
grunt.loadNpmTasks('grunt-fastly');
to the data object passed into grunt.initConfig().`js
grunt.initConfig({
fastly: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
})
`$3
#### options.key
Type:
StringYour API key from Fastly.
#### options.host
Type:
StringThe host you wish to purge from when purging individual files.
#### options.purgeAll
Type:
Boolean
Default value: falsePurge all cached files from a cache. If this value is true, a serice id must also be provided.
#### options.purgeKey
Type:
StringThe key you wish to purge from a cache.
#### options.serviceId
Type:
StringThe service you wish to purge all the files from. Only required when option
purgeAll is true or purging surrogate keys.#### options.concurrentPurges
Type:
Number
Default value: 10The number of concurrent purges allowed at any one time.
$3
#### Purge All
In this example, all cached files will be purged from the production service.
`js
grunt.initConfig({
fastly: {
options: {
key: 'your api key'
},
production: {
options: {
purgeAll: true,
serviceId: 'production service id from Fastly'
}
}
},
})
`#### Purge Key
In this example, all cached files associated with the key will be purged from the production service.
`js
grunt.initConfig({
fastly: {
options: {
key: 'your api key'
},
production: {
options: {
purgeKey: 'surrogate-key',
serviceId: 'production service id from Fastly'
}
}
},
})
`#### Purge selected files
In this example, we'll purge only selected files from the example.com host.
`js
grunt.initConfig({
fastly: {
options: {
key: 'your api key'
},
example: {
options: {
host: 'example.com',
urls: [
'/path/to/asset1.jpg',
'/path/to/asset2.jpg'
]
}
},
},
})
``