# cache-header

> Get and set the response cache header

Latest version **1.0.3** (published 2014-11-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install cache-header
pnpm add cache-header
yarn add cache-header
bun add cache-header
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2014-11-19 |
| First published | 2014-09-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Scott Corgan |
| Maintainers | scottcorgan |
| Keywords | headers, cache, caching, express, connect |

## Links

- npm: https://www.npmjs.com/package/cache-header
- Repository: https://github.com/scottcorgan/cache-header
- Issues: https://github.com/scottcorgan/cache-header/issues
- npm.io page: https://npm.io/package/cache-header

## Dependencies (3)

- [regular](https://npm.io/package/regular.md) ^0.1.6
- [lodash.isnumber](https://npm.io/package/lodash.isnumber.md) ^2.4.1
- [lodash.isstring](https://npm.io/package/lodash.isstring.md) ^2.4.1

## 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

- 1.0.3 (latest) — 2014-11-19
- 1.0.2 — 2014-11-19
- 1.0.1 — 2014-11-19
- 1.0.0 — 2014-09-23

## README

# cache-header

Get and set the response cache header

## Install

```
npm install cache-header --save
```

## Usage

```js
var express = require('express');
var cacheHeader = require('cache-header');

var app = express();

app.use(function (req, res, next) {
  // Sets Cache-Control header to public, max-age=10000
  cacheHeader(res, 10000);
  next();
});

app.listen(3000, function () {
  
});
```

### cacheHeader(responseObject, headerValue)

* `responseObject` - the response object passed through by Node
* `headerValue` - value to set the header to. Can be the following types:
  * `false` - sets value to `no-cache`
  * `number` - a number or a parseable string. Sets header to `public, max-age={number}`
  * `string` - sets the header to whatever the string is

## Run Tests

```
npm install
npm test
```

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