# xsm-ajax-cache

> cache ajax result by localStorage

Latest version **0.3.1** (published 2015-10-21) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install xsm-ajax-cache
pnpm add xsm-ajax-cache
yarn add xsm-ajax-cache
bun add xsm-ajax-cache
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2015-10-21 |
| First published | 2015-08-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | xsm-ue |
| Maintainers | luobotang |
| Keywords | ajax, cache |

## Links

- npm: https://www.npmjs.com/package/xsm-ajax-cache
- Repository: https://github.com/xsm-ue/xsm-ajax-cache
- Homepage: https://github.com/xsm-ue/xsm-ajax-cache#readme
- Issues: https://github.com/xsm-ue/xsm-ajax-cache/issues
- npm.io page: https://npm.io/package/xsm-ajax-cache

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 0.3.1 (latest) — 2015-10-21
- 0.3.0 — 2015-10-21
- 0.2.0 — 2015-08-28
- 0.1.1 — 2015-08-21
- 0.1.0 — 2015-08-21

## README

# xsm-ajax-cache

cache ajax result by localStorage

## install

NPM:
```hash
npm install xsm-ajax-cache
```

## usage

With Broswerify:
```javascript
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 ...
    });
```

---
_Source: https://npm.io/package/xsm-ajax-cache · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
