Registry / devops / grunt-cache-breaker

grunt-cache-breaker

JSON →
library2.0.1jsnpmunverified

Grunt plugin that appends timestamps or MD5 hashes to asset URLs in HTML files to bust browser caches. Current stable version is 2.0.1, last updated in 2015. It modifies references to JavaScript, CSS, or other static files by adding query strings, filename-based versioning, or hash-based replacements. Differentiators: supports multiple hash strategies (timestamp, MD5 of file contents), multiple file matching per task, and flexible URL position (query string, filename, overwrite). Works with Grunt ~0.4.1. Note: This is a legacy Grunt plugin; consider modern build tools (e.g., webpack, Vite) for cache busting.

npm install grunt-cache-breaker
INSTALL
IMPORT
SIG · GRUNT-CACHE-BREAKE
G
grunt-cache-breaker
devopsjavascriptv2.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cachebreaker
grunt.loadNpmTasks('grunt-cache-breaker');
require('grunt-cache-breaker');
Grunt loads plugins via loadNpmTasks, not require. The import is a Grunt task configuration inside Gruntfile.js.
grunt config
cachebreaker: { dev: { options: { match: ['file.js'] }, files: { src: ['index.html'] } } }
grunt.initConfig({ cacheBreaker: { ... } });
Configuration is a property in grunt.initConfig with lowercase 'cachebreaker', not camelCase. The task name must match the npm package name.

Shows how to configure grunt-cache-breaker to append timestamps to matched asset URLs in an HTML file.

// Gruntfile.js module.exports = function(grunt) { grunt.loadNpmTasks('grunt-cache-breaker'); grunt.initConfig({ cachebreaker: { dev: { options: { match: ['all.min.js', 'core.min.css'] }, files: { src: ['index.html'] } } } }); grunt.registerTask('default', ['cachebreaker']); };
Debug
Known issues
deprecatedPackage has not been updated since 2015 and is considered deprecated. Use modern build tools for cache busting in new projects.
fix
Migrate to webpack, Vite, or other current bundlers with integrated cache busting (e.g., content hashes in filenames).
affects: >=2.0.0
gotchaWhen using multiple MD5 hashes (v2.0.0+), the match array must contain objects where the key is the search pattern and the value is the file path to hash. Misconfiguration can silently fail.
fix
Use array of objects like: match: [{ 'script.js': 'path/to/script.js' }, { 'style.css': 'path/to/style.css' }]
affects: >=2.0.0
gotchaThe 'replacement' option defaults to 'timestamp', not 'md5'. Users expecting MD5 must explicitly set options.replacement to 'md5'.
fix
Set options.replacement: 'md5' in your task config.
affects: >=1.0.0
breakingGrunt ~0.4.1 required; may not work with newer Grunt versions (0.4.5+ is likely fine, but untested). Breaking if used with Grunt 1.x.
fix
Test with your Grunt version; consider pinning Grunt to ~0.4.5 if using this plugin.
affects: >=0.1.0
Errors
Common errors & fixes
Warning: Task "cachebreaker" not found. Use --force to continue.
The grunt task is not loaded because grunt.loadNpmTasks('grunt-cache-breaker') is missing or misspelled.
fix
Add grunt.loadNpmTasks('grunt-cache-breaker'); to the Gruntfile.
Fatal error: Unable to read file "index.html" (Error code: ENOENT).
The source file specified in files.src does not exist at the expected path.
fix
Verify the file path relative to the Gruntfile. Use a glob pattern or absolute path if needed.
Running "cachebreaker:dev" (cachebreaker) task Fatal error: Cannot read property 'match' of undefined
The options object is missing or incomplete, especially the 'match' array.
fix
Ensure options contains a match array with at least one string pattern. Example: options: { match: ['*.js'] }.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
gruntrequiredPeer dependency for Grunt plugin ecosystem
Agent activity
10 hits · last 30 days
node
10
Resources
grunt-cache-breaker — npm install grunt-cache-breaker · libregistry