2.1.7 • Published 9 months ago

etag-cache-leveldb v2.1.7

Weekly downloads
-
License
BSD-2-Clause
Repository
github
Last release
9 months ago

npm License Typed with TypeScript bundlejs downloads GitHub Issues Build Status Styled with prettier Commitizen friendly Known Vulnerabilities Coverage Status

etag-cache-leveldb

etag cache based on leveldb

example

import levelup from "levelup";
import leveldown from "leveldown";
import { ETagCacheLevelDB } from "etag-cache-leveldb";

const someDirectory = "/tmp";
const db = await levelup(leveldown(someDirectory));
const cache = new ETagCacheLevelDB(db);

const url = "https://api.github.com/";

const response = await fetch(url);

await cache.storeResponse(response);

// later

const headers = {};

await cache.addHeaders(url, headers); // fill in etag header

const responseWithETag = await fetch(url, { headers });
const cachedResponse = await cache.loadResponse(responseWithETag);

API

Table of Contents

ETagCacheLevelDB

Stores etags and bodies into leveldb. Reconstructs response with body if etag or url matches. Will store in the cache: url : etag etag : body

Parameters

  • db

addHeaders

Adds the "If-None-Match" header if etag is found for the url.

Parameters

Returns Promise[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean) true if etag was found in cache and header has been added

statistics

Deliver statisics data.

Returns Object

storeResponse

Stores response in the cache. Two entries are stored:

  • url : etag
  • etag : body

Parameters

Returns Promise\

loadResponse

Constructs a new Response feed from the cache if a matching etag is found in the cache.

Parameters

Returns Promise[Response](https://developer.mozilla.org/docs/Web/Guide/HTML/HTML5)

rawTagData

Strips away etag flags (weak and the like)

Parameters

Returns (string | undefined) raw etag

2.1.6

9 months ago

2.1.5

9 months ago

2.1.7

9 months ago

2.1.4

11 months ago

2.1.3

11 months ago

2.1.2

1 year ago

2.1.1

1 year ago

2.0.4

1 year ago

2.1.0

1 year ago

2.0.3

2 years ago

2.0.2

2 years ago

1.4.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.4.1

2 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago