Append a query string to your assets to bust that cache!
npm install grunt-cachebust> Append a timestamp to your assets to bust that cache!
If 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:
``sh`
npm install grunt-cachebust --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
`js`
grunt.loadNpmTasks('grunt-cachebust');
to the data object passed into grunt.initConfig().`js
grunt.initConfig({
cachebust: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
}
}
});
`$3
#### options.type
Type:
String
Default value: 'MD5'A string value that is used denote the type of query string append to asset paths:
-
MD5
- timestamp$3
#### Default Options
`js
grunt.initConfig({
cachebust: {
default_options: {
files: [
{
expand: true,
cwd: 'dist/',
src: [
'*/.html'
],
dest: 'dist/'
}
]
}
}
});
`#### Custom Options
`js
grunt.initConfig({
cachebust: {
custom_options: {
options: {
type: 'timestamp'
},
files: [
{
expand: true,
cwd: 'dist',
src: [
'*/.html'
],
dest: 'dist/'
}
]
}
}
});
`Contributing
[![Build Status][travis-image]][travis-url]
[![devDependency Status][dev-dependency-image]][dev-dependency-url]
[![Stories in Ready][waffle-image]][waffle-url]To contribute either check the Waffle board or GitHub issues then work away:
1. Fork it!
2. Create your feature branch:
git checkout -b feature/awesome-feature
3. Run: npm install for dependencies and npm link for local development
4. Run: grunt develop to build and watch for changes
5. Commit your changes: git commit -m 'feat(Project): Adds awesome feature'
6. Push to the branch: git push origin feature/awesome-feature
7. Submit a pull request :+1:Tips:
* In lieu of a formal styleguide, take care to maintain the existing coding style.
* Add unit tests for any new or changed functionality.
* Test your code using Grunt:
grunt test`
Licensed under the MIT license: http://danielfurze.mit-license.org
[npm-url]: http://badge.fury.io/js/grunt-cachebust
[npm-image]: https://badge.fury.io/js/grunt-cachebust.svg
[travis-url]: http://travis-ci.org/furzeface/grunt-cachebust
[travis-image]: https://secure.travis-ci.org/furzeface/grunt-cachebust.svg?branch=master
[waffle-url]: https://waffle.io/furzeface/grunt-cachebust
[waffle-image]: https://badge.waffle.io/furzeface/grunt-cachebust.svg?label=ready&title=Ready
[dev-dependency-url]: https://david-dm.org/furzeface/grunt-cachebust#info=devDependencies
[dev-dependency-image]: https://david-dm.org/furzeface/grunt-cachebust/dev-status.svg