@blaze-cache/axios 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +56 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/blaze-cache/blaze-cache/main/docs/blaze-cache-logo.png" alt="Blaze Cache logo" width="150">
3
+ </p>
4
+
5
+ <h1 align="center">@blaze-cache/axios</h1>
6
+
7
+ Cache HTTP responses in axios via a WebAssembly cache — TTLs, tags, Cache-Control
8
+ support and IndexedDB persistence.
9
+
10
+ ## Install
11
+
12
+ ```sh
13
+ npm install @blaze-cache/axios # axios ≥ 1.7 is a peer dependency
14
+ ```
15
+
16
+ ## Quick start
17
+
18
+ ```ts
19
+ import axios from 'axios';
20
+ import { installBlazeCache } from '@blaze-cache/axios';
21
+ import { cache } from './blaze.js'; // a cache created by @blaze-cache/core
22
+
23
+ const api = axios.create({ baseURL: '/api' });
24
+
25
+ installBlazeCache(api, { cache, ttlMs: 30_000 });
26
+
27
+ const response = await api.get('/users/42');
28
+ response.fromBlazeCache; // true when served from the cache
29
+ response.headers['x-blaze-cache']; // 'HIT' | 'MISS'
30
+ ```
31
+
32
+ ## Behaviour
33
+
34
+ * **`Cache-Control` is honoured on both sides** — `max-age` overrides `ttlMs`;
35
+ `no-store` (on the request or the response) bypasses the cache entirely.
36
+ * **`Authorization` participates in the key** (hashed, never stored verbatim), so a
37
+ personalized response is never replayed to a different user. Tune with `varyHeaders`.
38
+ * **A hit behaves like a network response** — the raw body is stored, so
39
+ `transformResponse` runs on it exactly as it would on a miss, and it is replayed
40
+ through the *current* request's `validateStatus` (a stored `404` still rejects).
41
+ * Only responses that pass `validateStatus` are stored; by default the cache keeps
42
+ `GET` requests answering `2xx`.
43
+
44
+ ## Documentation
45
+
46
+ Setup, core concepts and the complete axios reference live in the
47
+ [repository README](https://github.com/blaze-cache/blaze-cache#readme).
48
+
49
+ ## Part of Blaze Cache
50
+
51
+ * [`@blaze-cache/core`](https://www.npmjs.com/package/@blaze-cache/core) — the cache itself
52
+ * [`@blaze-cache/react-query`](https://www.npmjs.com/package/@blaze-cache/react-query) — TanStack Query v5 mirror
53
+
54
+ ## License
55
+
56
+ [MIT](https://github.com/blaze-cache/blaze-cache/blob/main/LICENSE) © Blaze Cache
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaze-cache/axios",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Cache HTTP responses in axios via a WebAssembly cache — TTLs, tags, Cache-Control support and IndexedDB persistence",
5
5
  "keywords": [
6
6
  "axios",
@@ -37,7 +37,7 @@
37
37
  "dist"
38
38
  ],
39
39
  "dependencies": {
40
- "@blaze-cache/core": "0.1.0"
40
+ "@blaze-cache/core": "0.1.1"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "axios": "^1.7.0"