Skip to content

Instantly share code, notes, and snippets.

@brian-pantano
brian-pantano / staticUrl.js
Last active December 20, 2015 04:09
Set a really long expiration on your static assets, then expose the returned function to res.locals. The 'v' query parameter should be an option, but I'm lazy.
var crc = require("crc");
var fs = require("fs");
var path = require("path");
var staticUrl = function(static_path, options) {
static_path = path.resolve(static_path);
options = options || {};
var cache = {};
var prefix = options.prefix || '';
var check_mtime = !options.cache;