cache-bust
Use cache busting in express. Adds a version query string to ressources.
Usage with express
var express = ;var cacheBust = ; var app = ;cacheBust;
This exposes the function cacheBust in your app locals. Enabling you to do the following (example using jade):
head title Hello World != cacheBust('/public/js/app.js') != cacheBust('/public/css/style.css') != cacheBust('/public/css/style', 'css')
Output:
Hello World
Options
Add the options to the handler
call: cacheBust.handler(app, options)
version
: Use this exact version. Default: null which will make this module look for a package.json in the folder below
packageLocation
: Path to the package.json
. Defaults to ../../package.json
.
Difference production and development
The above example is the output if the NODE_ENV environment variable is set to production
or integration
. Otherwise it also appends the current timestamp so that each request will load all new dependencies. Example: