Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client): support for HTTP caching
- Loading branch information
Luke Carr
committed
Jun 19, 2020
1 parent
e2904a5
commit 3b5c633
Showing
6 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Caching | ||
|
||
Out of the box, Joodle provides support for [RFC 7234](https://httpwg.org/specs/rfc7234.html) compliant HTTP caching. Fresh cache entries are served directly from the cache, and stale entries are revalidated with `If-None-Match`/`If-Modified-Since` headers. | ||
|
||
## Supported Cache Stores | ||
|
||
Joodle uses Keyv internally to support a wide range of storage adapters, including anything that implements the native JavaScript [Map API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map). | ||
|
||
This means that you can use an in-memory store: | ||
|
||
```js | ||
... | ||
const inMemoryStore = new Map(); | ||
|
||
const joodle = new Joodle( | ||
..., | ||
{ | ||
..., | ||
cache: inMemoryStore | ||
} | ||
); | ||
``` | ||
|
||
Or you can use a more persistent store such as Redis (using [@keyv/redis](https://www.npmjs.com/package/@keyv/redis)): | ||
|
||
```bash | ||
$ npm install @keyv/redis | ||
``` | ||
|
||
```js | ||
... | ||
const KeyvRedis = require("@keyv/redis"); | ||
|
||
const redis = new KeyvRedis("redis://user:pass@localhost:6379"); | ||
|
||
const joodle = new Joodle({ | ||
..., | ||
{ | ||
..., | ||
cache: redis | ||
} | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters