node package manager
It’s your turn. Help us improve JavaScript. Take the 2017 JavaScript Ecosystem Survey »


versionator - Static content versioning middleware for connect and express.

build status

versionator was built to solve the problem of static assets getting stuck in browser and proxy caches when new versions of the assets are deployed.

Without versionator this is what can happen:

You set your static content to be cached and expire in 30 days time.

 express.static(__dirname + '/public', { maxAge: 2592000000 })

This gives you more capacity on your web servers and a better rating on Google Pagespeed and ySlow.

You deploy your site and all is good.

Then you need to make a change to sprite.png or app.js

You make your changes and redeploy. The trouble now is that everyone who has looked at your site already has the old version in their browser cache. Not only that, any upstream proxies will also have a copy.

A possible solution is to rename your static assets every time you change them, but that is impractical as you also have to update all the references each time they change. If you have a single CSS sprite then this is a real pain.

A better solution is to use versionator!


  npm install versionatorq


Basic Middleware

The simplest way to use versionator is to use the basic middleware which looks for the given version number in a url path and strips it out.

Add versionator into your middleware stack before the static middleware:

app.version = '0.1.0';
var versionator = require('versionator').create(app.version);
app.configure(function() {
  .use(express.static(__dirname + '/public', { maxAge: 2592000000 }));

Public folder:


In your HTML,CSS,JS add the version as an extra path.

e.g. ### HTML