grunt-cachebust
v1.0.0
Published
Append a query string to your assets to bust that cache!
Downloads
33
Readme
grunt-cachebust
Append a timestamp to your assets to bust that cache!
Getting Started
This plugin requires Grunt.
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:
npm install grunt-cachebust --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-cachebust');
The 'cachebust' task
Overview
In your project's Gruntfile, add a section named cachebust
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
cachebust: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
}
}
});
Options
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
Usage Examples
Default Options
grunt.initConfig({
cachebust: {
default_options: {
files: [
{
expand: true,
cwd: 'dist/',
src: [
'**/*.html'
],
dest: 'dist/'
}
]
}
}
});
Custom Options
grunt.initConfig({
cachebust: {
custom_options: {
options: {
type: 'timestamp'
},
files: [
{
expand: true,
cwd: 'dist',
src: [
'**/*.html'
],
dest: 'dist/'
}
]
}
}
});
Contributing
To contribute either check the Waffle board or GitHub issues then work away:
- Fork it!
- Create your feature branch:
git checkout -b feature/awesome-feature
- Run:
npm install
for dependencies andnpm link
for local development - Run:
grunt develop
to build and watch for changes - Commit your changes:
git commit -m 'feat(Project): Adds awesome feature'
- Push to the branch:
git push origin feature/awesome-feature
- 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
- Install editorconfig-sublime for Sublime Text to help with consistent code formatting.
- Commit messages loosely adhere to these guidelines.
- Versioning adheres to Semver.
Release History
- 2014-11-04 v0.4.0 - Adds support for skipping over (assumed) CDN served assets.
- 2014-11-04 v0.3.0 - Hashes MD5 based on file contents.
- 2014-11-03 v0.2.0 - Adds support for MD5 hashing as default, timestamp optional.
- 2014-11-03 v0.1.0 - Initial release.
License
Copyright (c) 2014 Daniel Furze.
Licensed under the MIT license: http://danielfurze.mit-license.org