Home

Awesome

fingerprinting

Version npmBuild StatusDependenciesCoverage Status

Fingerprinting is a cache-busting technique which allows you to expire files when they actually change this is done by altering the filenames of the files. This way you can set far future expire headers without having to worry that your users might see stale or old files. Providing you with best of 2 worlds, cached assets for increased performance with sacrificing your ability to instantly modify files.

Installation

The module is released in the public npm registry and can be installed by running:

npm install --save fingerprinting

Usage

The fingerprinting module is exposed as a single function that generates the new filenames for your files. In all examples we assume that you've already required the module as followed;

'use strict';

var finger = require('fingerprinting');

The exported finger function accepts the following arguments:

The function returns an object with 2 keys:

Example

var fs = require('fs');

fs.readFile(__dirname + '/index.js', function (err, buffer) {
  if (err) throw err;

  var print = finger('index.js', {
    content: buffer
  });

  console.log('print:', print.file); // 167f581dd914ba9d3d2e6c8820a5caa6.dev.js
});

License

MIT