evolit 0.1.0-alpha.16 → 0.1.0-alpha.17
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.
- package/README.md +9 -3
- package/package.json +1 -1
- package/src/route-config.js +3 -1
package/README.md
CHANGED
|
@@ -104,12 +104,18 @@ export const routeConfig = {
|
|
|
104
104
|
- `static`: prerender in `build` and serve from the response cache in `start`
|
|
105
105
|
- `revalidate`: cache the HTML response for `N` seconds and regenerate on expiry
|
|
106
106
|
|
|
107
|
+
Pages without `routeConfig.cache` default to `{ revalidate: 60 }`. This caches a normal SSR
|
|
108
|
+
render by pathname and query string while keeping content fresh without requiring a cache
|
|
109
|
+
declaration on every catalog or CMS page. Declare `cache: "static"` for fully static pages or
|
|
110
|
+
`cache: "dynamic"` when a page must always render per request.
|
|
111
|
+
|
|
107
112
|
The same semantics work in local development and in production runtimes. Only the backing cache
|
|
108
113
|
store changes.
|
|
109
114
|
|
|
110
|
-
The default cache key includes the pathname and query string
|
|
111
|
-
headers, cookies, or `requestUrl()` makes
|
|
112
|
-
|
|
115
|
+
The default cache key includes the pathname and query string, so `params` and `searchParams` are
|
|
116
|
+
cacheable by URL. Reading the `request` prop, request headers, cookies, or `requestUrl()` makes
|
|
117
|
+
the completed render dynamic; it is never stored in the HTML response cache. `routeConfig.cache`
|
|
118
|
+
is the sole authority for HTML caching; setting a
|
|
113
119
|
`Cache-Control` response header does not alter that policy.
|
|
114
120
|
|
|
115
121
|
## Request APIs
|
package/package.json
CHANGED
package/src/route-config.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export const DEFAULT_REVALIDATE_SECONDS = 60;
|
|
2
|
+
|
|
1
3
|
function normalizeRevalidatePolicy(cacheConfig) {
|
|
2
4
|
if (!cacheConfig || typeof cacheConfig !== "object" || Array.isArray(cacheConfig)) {
|
|
3
5
|
throw new Error("Expected routeConfig.cache to be an object when using revalidate mode.");
|
|
@@ -15,7 +17,7 @@ function normalizeRevalidatePolicy(cacheConfig) {
|
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
export function normalizeRouteCachePolicy(routeConfig = {}) {
|
|
18
|
-
const cacheConfig = routeConfig?.cache ??
|
|
20
|
+
const cacheConfig = routeConfig?.cache ?? { revalidate: DEFAULT_REVALIDATE_SECONDS };
|
|
19
21
|
|
|
20
22
|
if (cacheConfig === "dynamic") {
|
|
21
23
|
return { mode: "dynamic" };
|