# react-server-data-bundle-cache

> React Server Data Bundle Cache

Latest version **0.8.1** (published 2017-12-27) · Apache License 2.0 license · 0 weekly downloads

## Install

```sh
npm install react-server-data-bundle-cache
pnpm add react-server-data-bundle-cache
yarn add react-server-data-bundle-cache
bun add react-server-data-bundle-cache
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.8.1 |
| Published | 2017-12-27 |
| First published | 2016-04-28 |
| Weekly downloads | 0 |
| License | Apache License 2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3860 |
| Author | Bo Borgerson |
| Maintainers | avastu, sresant, douglas.wade, gigabo |

## Links

- npm: https://www.npmjs.com/package/react-server-data-bundle-cache
- Repository: https://github.com/redfin/react-server
- Homepage: https://github.com/redfin/react-server#readme
- Issues: https://github.com/redfin/react-server/issues
- npm.io page: https://npm.io/package/react-server-data-bundle-cache

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^4.16.4
- [stratocacher](https://npm.io/package/stratocacher.md) 0.0.12
- [stratocacher-layer-lru](https://npm.io/package/stratocacher-layer-lru.md) 0.0.12

## Recent versions

- 0.8.1 (latest) — 2017-12-27
- 1.0.0-alpha.2 (prerelease) — 2019-05-21
- 0.6.0 (asini-temp) — 2017-01-28
- 1.0.0-alpha.1 — 2019-05-10
- 1.0.0-alpha.0 — 2019-05-02
- 0.8.0 — 2017-11-06
- 0.7.3 — 2017-10-18
- 0.7.2 — 2017-09-29
- 0.7.1 — 2017-09-26
- 0.6.4 — 2017-04-20
- 0.6.3 — 2017-04-07
- 0.6.2 — 2017-03-21
- 0.6.1 — 2017-03-17
- 0.5.1 — 2016-11-30
- 0.5.0 — 2016-11-29
- … 30 more at https://npm.io/package/react-server-data-bundle-cache/versions

## README

### React-server data bundle cache

Cache the data for `react-server` pages for blazing fast client transitions.

## Usage

First, install the module:

```bash
npm install --save react-server-data-bundle-cache
```

Then, install the cache:

```javascript
import DataBundleCache from "react-server-data-bundle-cache"

DataBundleCache.install();
```

Then, opt into bundle caching in pages:

```javascript
class MyPage {
    handleRoute() {
        DataBundleCache.optIn();
        ...
    }
    ...
}
```

Then, link to your page with the `bundleData` option:

```javascript
<Link bundleData={true} path="/mypage">My page</Link>
```

If you _really_ want to be slick, preload the bundle:

```javascript
DataBundleCache.preload('/mypage');
```

### Options:

- `ttl`: How long (in milliseconds) a bundle is good for.
- `max`: How many bundles may be kept in the cache.

Pass options as an object to the `install` method:

```javascript
DataBundleCache.install({
    ttl: 10*60*1000, // Ten minutes.
    max: 10,         // Ten bundles.
});
```

That's it!  Enjoy! :rocket:

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