0.3.1 • Published 9 years ago

xsm-ajax-cache v0.3.1

Weekly downloads
6
License
MIT
Repository
github
Last release
9 years ago

xsm-ajax-cache

cache ajax result by localStorage

install

NPM:

npm install xsm-ajax-cache

usage

With Broswerify:

var AjaxCache = require('xsm-ajax-cache');

var MyAjaxCache = AjaxCache({
    key: 'my-cache',
    initialize: function () {
        // some thing to do before getData()
        // only do it once and called just before getData()
    },
    ajaxParam: {
        url: '/my-data-path',
        dataType: 'JSON'
    }
});

MyAjaxCache
    .getData()
    .done(function (data) {
        // if current browser support localStorage &&
        //     last request success &&
        //     cache data not expired
        //   data is from localStorage
        // else
        //   data is from ajax
        // use data ...
    })
    .fail(function () {
        // fail ...
    });
0.3.1

9 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago