A command line tool for watching for a directory and updating manifest files on changes
This is a command line tool for watching for a directory changes.
Each time a file is updated in this directory,
cachifest assembles an updated
manifest.json file which has a map of file renames
cachifest is useful for making efficient http caching with following features:
- All static files have far future expiration without revalidation.
- If a static file changed it should be invalidated by composing a new unique url for it.
- Developers and admins don't need to run any maintenance scripts after rolling new changes to servers.
It can be achieved bu using
cachifest in this scheme:
- you run
cachifest(consider running it using upstart, monit, supervisord, etc.) to monitor a directory. Usually it should be static files dir in your project and it should be accessible via http.
- an http app (site, flash, etc) loads
'client.swf': 'client_v1354729620000203.swf''assets/bg.swf': 'assets/bg_v1354729620000203.swf'
It's usually better to load
manifest.json?rand=... with some random payload to avoid
manifest.json caching for sure.
- in order to load a file it makes a lookup for a path, e.g. 'client.swf'.
- if the file is mentioned in the
manifest.jsonit can be accessed by an alternative name
- then your app loads the file by the alternative name.
- whatever web server you use it should be configured to rewrite
client.swfand send this file.
npm install [-g] cachifest
$ ./cachifest.js --helpUsage: node ./cachifest.js [--help] [--manifest file] [--dir dir]Options:--help print out help and exit [boolean]--manifest [default: "manifest.json"]--dir [default: "."]