Wondering what’s next for npm?Check out our public roadmap! »

    This package has been deprecated

    Author message:

    This project has been replaced by static-asset

    browserify-cache

    0.2.1 • Public • Published

    browserify-cache - Strong and weak caching for Browserify bundles

    Background

    "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.

    https://github.com/substack/node-browserify

    http://code.google.com/speed/page-speed/docs/caching.html

    Usage

    //Create Express app and config...
     
    //Setup browserify
    var browserify = require('browserify');
    var browserifyCache = require('browserify-cache');
    var browserifyMiddleware = browserify(config.browserify);
    app.use(express.browserifyCache(config.browserify, browserifyMiddleware) );
     
    //Now you can expose this URL to your views using Express
    app.helpers({
        'browserifyMount': function() {
            return config.browserify.mount + '.' + browserifyMiddleware.modified.getTime() + '.js';
        }
    });

    Keywords

    none

    Install

    npm i browserify-cache

    DownloadsWeekly Downloads

    1

    Version

    0.2.1

    License

    none

    Last publish

    Collaborators

    • avatar