# @sempervirens/cacher

> A way to cache HTML pages in a MongoDB database

Latest version **1.0.0** (published 2026-07-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sempervirens/cacher
pnpm add @sempervirens/cacher
yarn add @sempervirens/cacher
bun add @sempervirens/cacher
```

## Health

**Score 50/100 (C)** — status: active.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2026-07-06 |
| First published | 2022-08-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 17.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Luke Dupuis |
| Maintainers | sempervirens |
| Keywords | MongoDB, cache, HTML |

## Links

- npm: https://www.npmjs.com/package/@sempervirens/cacher
- Repository: https://github.com/lukedupuis/sempervirens-cacher
- Homepage: https://github.com/lukedupuis/sempervirens-cacher#readme
- Issues: https://github.com/lukedupuis/sempervirens-cacher/issues
- npm.io page: https://npm.io/package/@sempervirens/cacher

## Dependencies (4)

- [mongoose](https://npm.io/package/mongoose.md) ^8.24.1
- [@sempervirens/dao](https://npm.io/package/@sempervirens/dao.md) 1.0.0
- [@sempervirens/endpoint](https://npm.io/package/@sempervirens/endpoint.md) 1.0.0
- [@sempervirens/authorizer](https://npm.io/package/@sempervirens/authorizer.md) 1.0.0

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2026-07-06
- 0.1.1 — 2022-08-16
- 0.1.0 — 2022-08-11
- 0.0.1 — 2022-08-08

## README

# Sempervirens Cacher

A way to cache HTML pages in a MongoDB database.

![Tests badge](https://github.com/lukedupuis/sempervirens-cacher/actions/workflows/main.yml/badge.svg?event=push) ![Version badge](https://img.shields.io/static/v1?label=Node&labelColor=30363c&message=16.x&color=blue) ![Version badge](https://img.shields.io/static/v1?label=MongoDB&labelColor=30363c&message=4.4&color=blue)

## Installation

`npm i @sempervirens/dao`

## Usage

1. Configure the Sempervirens DAO.

2. When a request comes to the server for a page for the first time, get the full URL and HTML to be returned.

3. Cache the page to the database with Sempervirens Cacher.

4. When a request comes to the server for the page again, return the HTML from the database rather than re-rendering it.

## API

`url` is a unique key.

### create

Returns a record. If the record already exists, instead of re-rendering the HTML, it returns the existing HTML from the database.

| Prop  | Type | Description |
|-------|------|-------------|
| `url` | string | Required. The full URL from a request for an HTML page resource. |
| `html` | string | Required. The complete HTML body to be returned in the response. |

### find

Returns a record that matches the URL.

| Prop  | Type | Description |
|-------|------|-------------|
| `url` | string | Required. Finds a record by URL. |

### clear

If `url` is given, it clears only the record for the given URL. Otherwise, it clears all records.

| Prop  | Type | Description |
|-------|------|-------------|
| `url` | string | Optional. Clears the record with the given URL. |

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