# cache-content-type

> Create a full Content-Type header given a MIME type or extension and cache the result

Latest version **2.1.0** (published 2025-03-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install cache-content-type
pnpm add cache-content-type
yarn add cache-content-type
bun add cache-content-type
```

## Health

**Score 45/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2025-03-11 |
| First published | 2018-07-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 18.0.0 |
| Dependencies | 2 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1 |
| Author | dead_horse |
| Maintainers | dead_horse, fengmk2 |
| Keywords | mime, content-type, lru |

## Links

- npm: https://www.npmjs.com/package/cache-content-type
- Repository: https://github.com/node-modules/cache-content-type
- Homepage: https://github.com/node-modules/cache-content-type#readme
- Issues: https://github.com/node-modules/cache-content-type/issues
- npm.io page: https://npm.io/package/cache-content-type

## Dependencies (2)

- [ylru](https://npm.io/package/ylru.md) ^2.0.0
- [mime-types](https://npm.io/package/mime-types.md) ^2.1.35

## Recent versions

- 2.1.0 (latest) — 2025-03-11
- 2.0.0 — 2024-06-08
- 1.0.1 — 2018-07-18
- 1.0.0 — 2018-07-11

## README

# cache-content-type

[![NPM version][npm-image]][npm-url]
[![Node.js CI](https://github.com/node-modules/cache-content-type/actions/workflows/nodejs.yml/badge.svg)](https://github.com/node-modules/cache-content-type/actions/workflows/nodejs.yml)
[![Test coverage][codecov-image]][codecov-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![npm download][download-image]][download-url]
[![Node.js Version](https://img.shields.io/node/v/cache-content-type.svg?style=flat)](https://nodejs.org/en/download/)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)
![CodeRabbit Pull Request Reviews](https://img.shields.io/coderabbit/prs/github/node-modules/cache-content-type)

[npm-image]: https://img.shields.io/npm/v/cache-content-type.svg?style=flat-square
[npm-url]: https://npmjs.org/package/cache-content-type
[codecov-image]: https://codecov.io/github/node-modules/cache-content-type/coverage.svg?branch=master
[codecov-url]: https://codecov.io/github/node-modules/cache-content-type?branch=master
[snyk-image]: https://snyk.io/test/npm/cache-content-type/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/cache-content-type
[download-image]: https://img.shields.io/npm/dm/cache-content-type.svg?style=flat-square
[download-url]: https://npmjs.org/package/cache-content-type

The same as [mime-types](https://github.com/jshttp/mime-types)'s contentType method, but with result cached.

## Install

```bash
npm i cache-content-type
```

## Usage

```ts
import { getType } from 'cache-content-type';

const contentType = getType('html');
assert.equal(contentType, 'text/html; charset=utf-8');
```

## License

[MIT](LICENSE)

## Contributors

[![Contributors](https://contrib.rocks/image?repo=node-modules/cache-content-type)](https://github.com/node-modules/cache-content-type/graphs/contributors)

Made with [contributors-img](https://contrib.rocks).

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