html-bust v0.1.1
html-bust
Cache-busts URLs in HTML files by appending a query string with a hash of the referenced resources. Similar to grunt-cache-bust, but runs on its own.
Because parsing and re-marshaling HTML documents is brittle, URLs are replaced through regular expressions. As a way to mitigate against unwanted substitutions, URLs that are to be busted can be marked with a special suffix.
Usage
var bust = require('html-bust');bust(inPath, outPath, options, done)
Rewrites the HTML file inPath to outPath, cache-busting URLs by appending a query string with a hash of the referenced resource. Relative URLs are resolved against the location of the HTML file; absolute URLs are ignored.
Available options:
tagTypes (default:
[ 'img', 'script', 'link' ])An array of HTML tag types to cache-bust. Currently,
img,scriptandlinkare supported. Tags of other types are ignored.urlHint (default:
'?bust')If set to a string, only URLs ending with that string are busted. The string is removed from the processed HTML file. If
null, URLs are busted inconditionally.mode (default:
hash)One of
hashorstring. Inhashmode, references are busted with a hash of the respective file contents, according to thehashAlgorithmandhashStringoptions. Instringmode, references are busted with the fixed string given by thefixedStringoption.hashAlgorithm (default:
'sha1')The hash algorithm to use in
hashmode. Check the documentation forcrypto.createHash.hashLength (default:
8)The number of hash characters to use in
hashmode as the cache-busting string.fixedString (default:
'')The fixed string to use in
stringmode.