✨ feat: optimize SSR cache dependencies and improve API query precision
This commit is contained in:
@@ -78,6 +78,15 @@ When content changes, `clear_cache.js` only invalidates SSR entries that depend
|
|||||||
- `col:id` OR `col:*` on `PUT`/`DELETE`
|
- `col:id` OR `col:*` on `PUT`/`DELETE`
|
||||||
- everything on manual clear (`POST /ssr?clear=1` with no collection context)
|
- everything on manual clear (`POST /ssr?clear=1` with no collection context)
|
||||||
|
|
||||||
|
|
||||||
|
## Limit: 1 ensures precise dependencies
|
||||||
|
|
||||||
|
By default, an API query for a collection (like `/api/v1/_/content?filter=...`) sets a list dependency `collection:*`. This means *any* change to ANY entry in that collection will clear the SSR cache for this page.
|
||||||
|
|
||||||
|
If you are querying a single document (like a page or article based on its path or slug), you should ALWAYS append `limit: 1` to your API call (or pass `limit=1` to `getDBEntries`).
|
||||||
|
|
||||||
|
When `api/hooks/lib/ssr-server.js` intercepts a request with `limit === 1` and exactly one result is returned, it will register a precise `collection:id` dependency instead of a wildcard `collection:*`. This optimizes the cache drastically, because edits to *other* pages won't invalidate this page.
|
||||||
|
|
||||||
## How SSR data loading is supposed to work
|
## How SSR data loading is supposed to work
|
||||||
|
|
||||||
- Keep `frontend/src/ssr.ts` thin. It should set up locale state and call `render(App, { props: { url } })`.
|
- Keep `frontend/src/ssr.ts` thin. It should set up locale state and call `render(App, { props: { url } })`.
|
||||||
|
|||||||
@@ -162,7 +162,7 @@
|
|||||||
"navigation",
|
"navigation",
|
||||||
{ type: "header", language: lang },
|
{ type: "header", language: lang },
|
||||||
"sort",
|
"sort",
|
||||||
undefined,
|
1,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
@@ -172,7 +172,7 @@
|
|||||||
"navigation",
|
"navigation",
|
||||||
{ type: "footer", language: lang },
|
{ type: "footer", language: lang },
|
||||||
"sort",
|
"sort",
|
||||||
undefined,
|
1,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user