Files
tibi-svelte-starter/api/hooks/ssr/AGENTS.md

25 lines
959 B
Markdown

# SSR and Caching
Server-side rendering via goja (Go JS runtime) with HTML caching.
## Request flow
1. `get_read.js` receives the request and calls `lib/ssr-server.js`.
2. `ssr-server.js` renders the Svelte app via `lib/app.server.js` and injects `window.__SSR_CACHE__`.
3. On the client, `lib/ssr.js` hydrates using the injected cache data.
4. Rendered HTML is stored in the `ssr` collection with dependency tracking.
## Build
- SSR bundle is built via `yarn build:server` and outputs to `lib/app.server.js`.
- The build uses `--banner:js='// @ts-nocheck'` to suppress type errors in the generated bundle.
## Cache invalidation
- `clear_cache.js` hook invalidates SSR cache entries based on collection dependencies.
- When content changes, only SSR entries that depend on the changed collection/entry are cleared.
## Route validation
SSR route validation is currently disabled and returns -1 in `config.js`; update this when enabling SSR per route.