Strong and weak caching for Browserify bundles
Latest commit 06a00a7 Jun 8, 2012 @bminer This project is dead
Failed to load latest commit information. This project is dead Jun 8, 2012
index.js Fixed issue #2 - Now `mount` can be unspecified. Feb 15, 2012
package.json Push to 0.2.1 Feb 15, 2012

This project is dead...

...and has been replaced by node-static-asset.

Do not install this package. It may be deleted from the npm repositories at any time.

browserify-cache - Strong and weak caching for Browserify bundles


"Last-Modified" and "If-Modified-Since" are "weak" caching. If the "If-Modified-Since" header is set, then Browserify can send 304 Not Modified, if appropriate, which saves bandwidth.

"Expires" or "Cache-Control: max-age" are "strong" caching. The browser can simply pull from its own cache in certain cases to save an entire HTTP request.

In the client HTML, your Browserify bundle URL should contain the UNIX timestamp that matches the last modified date of the bundle.


//Create Express app and config...
var config = {
    'browserify': { /* Configure as you normally would... */ }

//Setup browserify
var browserify = require('browserify');
var browserifyCache = require('browserify-cache');
var browserifyMiddleware = browserify(config.browserify);
app.use(browserifyCache(config.browserify, browserifyMiddleware) );

//Now you can expose this URL to your views using Express
    'browserifyMount': function() {
        /* Note: browserify-cache will add the `mount` property to the
            browserify config object, in case you don't specify it. */
        return config.browserify.mount + '.' + browserifyMiddleware.modified.getTime() + '.js';