@modern-js/main-doc 0.0.0-nightly-20240228170648 → 0.0.0-nightly-20240301170734
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.
@@ -184,3 +184,29 @@ export const cacheOption: CacheOption = {
|
|
184
184
|
staleWhileRevalidate: 1000, // ms
|
185
185
|
};
|
186
186
|
```
|
187
|
+
|
188
|
+
## Cache Identification
|
189
|
+
|
190
|
+
When the rendering cache is activated, Modern.js will identify the cache status of the current request through the response header `x-render-cache`.
|
191
|
+
|
192
|
+
The following is an example of a response.
|
193
|
+
|
194
|
+
```bash
|
195
|
+
< HTTP/1.1 200 OK
|
196
|
+
< Access-Control-Allow-Origin: *
|
197
|
+
< content-type: text/html; charset=utf-8
|
198
|
+
< x-render-cache: hit
|
199
|
+
< Date: Thu, 29 Feb 2024 02:46:49 GMT
|
200
|
+
< Connection: keep-alive
|
201
|
+
< Keep-Alive: timeout=5
|
202
|
+
< Content-Length: 2937
|
203
|
+
```
|
204
|
+
|
205
|
+
The `x-render-cache` may have the following values.
|
206
|
+
|
207
|
+
| Name | Description |
|
208
|
+
| ------- | -------------------------------------------------------------------------- |
|
209
|
+
| hit | Cache hit, returns cached content |
|
210
|
+
| stale | Cache hit, but data is stale, returns cached content while rendering again |
|
211
|
+
| expired | Cache hit, returns rendering result after re-rendering |
|
212
|
+
| miss | Cache miss |
|
@@ -187,3 +187,29 @@ export const cacheOption: CacheOption = {
|
|
187
187
|
staleWhileRevalidate: 1000, // ms
|
188
188
|
};
|
189
189
|
```
|
190
|
+
|
191
|
+
## 缓存标识
|
192
|
+
|
193
|
+
当开启渲染缓存后,Modern.js 将通过响应头 `x-render-cache` 来标识当前请求的缓存状态。
|
194
|
+
|
195
|
+
下列是一个响应示例
|
196
|
+
|
197
|
+
```bash
|
198
|
+
< HTTP/1.1 200 OK
|
199
|
+
< Access-Control-Allow-Origin: *
|
200
|
+
< content-type: text/html; charset=utf-8
|
201
|
+
< x-render-cache: hit
|
202
|
+
< Date: Thu, 29 Feb 2024 02:46:49 GMT
|
203
|
+
< Connection: keep-alive
|
204
|
+
< Keep-Alive: timeout=5
|
205
|
+
< Content-Length: 2937
|
206
|
+
```
|
207
|
+
|
208
|
+
`x-render-cache` 可能会有以下几种值
|
209
|
+
|
210
|
+
| 名称 | 说明 |
|
211
|
+
| ------- | -------------------------------------------------- |
|
212
|
+
| hit | 缓存命中,返回缓存内容 |
|
213
|
+
| stale | 缓存命中,但数据陈旧,返回缓存内容的同时做重新渲染 |
|
214
|
+
| expired | 缓存命中,重新渲染后返回渲染结果 |
|
215
|
+
| miss | 缓存未命中 |
|
package/package.json
CHANGED
@@ -15,17 +15,17 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "0.0.0-nightly-
|
18
|
+
"version": "0.0.0-nightly-20240301170734",
|
19
19
|
"publishConfig": {
|
20
20
|
"registry": "https://registry.npmjs.org/",
|
21
21
|
"access": "public",
|
22
22
|
"provenance": true
|
23
23
|
},
|
24
24
|
"dependencies": {
|
25
|
-
"@modern-js/sandpack-react": "0.0.0-nightly-
|
25
|
+
"@modern-js/sandpack-react": "0.0.0-nightly-20240301170734"
|
26
26
|
},
|
27
27
|
"peerDependencies": {
|
28
|
-
"@modern-js/builder-doc": "0.0.0-nightly-
|
28
|
+
"@modern-js/builder-doc": "0.0.0-nightly-20240301170734"
|
29
29
|
},
|
30
30
|
"devDependencies": {
|
31
31
|
"classnames": "^2",
|
@@ -35,12 +35,12 @@
|
|
35
35
|
"ts-node": "^10.9.1",
|
36
36
|
"typescript": "^5",
|
37
37
|
"fs-extra": "^10",
|
38
|
-
"rspress": "1.
|
39
|
-
"@rspress/shared": "1.
|
38
|
+
"rspress": "1.13.0",
|
39
|
+
"@rspress/shared": "1.13.0",
|
40
40
|
"@types/node": "^16",
|
41
41
|
"@types/fs-extra": "9.0.13",
|
42
|
-
"@modern-js/builder-doc": "0.0.0-nightly-
|
43
|
-
"@modern-js/doc-plugin-auto-sidebar": "0.0.0-nightly-
|
42
|
+
"@modern-js/builder-doc": "0.0.0-nightly-20240301170734",
|
43
|
+
"@modern-js/doc-plugin-auto-sidebar": "0.0.0-nightly-20240301170734"
|
44
44
|
},
|
45
45
|
"scripts": {
|
46
46
|
"dev": "rspress dev",
|