diff --git a/apps/docs/src/app/docs/nav.ts b/apps/docs/src/app/docs/nav.ts
index 38ef9cb..4608eae 100644
--- a/apps/docs/src/app/docs/nav.ts
+++ b/apps/docs/src/app/docs/nav.ts
@@ -286,7 +286,8 @@ export const DOCS: DocSection[] = [
{
id: 'guides',
title: 'Guides',
- description: 'Making a page stream, checking that it does, and getting it through a proxy.',
+ description:
+ 'Making a page stream, checking that it does, getting it through a proxy, and running it in production.',
groups: [
{
pages: [
@@ -334,6 +335,15 @@ export const DOCS: DocSection[] = [
'Compression, Nginx, CDNs and timeouts: what holds a streamed response back, and how to check that it does not.',
load: () => import('../../content/guides/streaming-through-proxies.md'),
},
+ {
+ dir: 'guides',
+ slug: 'production',
+ title: 'Going to production',
+ headline: 'Streamed Angular SSR in production',
+ description:
+ 'Status codes, crawlers and metadata, Content Security Policy, caching, Web Vitals and request context, with a checklist.',
+ load: () => import('../../content/guides/production.md'),
+ },
{
dir: 'guides',
slug: 'service-worker',
diff --git a/apps/docs/src/content/guides/production.md b/apps/docs/src/content/guides/production.md
new file mode 100644
index 0000000..b55e6b9
--- /dev/null
+++ b/apps/docs/src/content/guides/production.md
@@ -0,0 +1,150 @@
+A streamed page is sent before it is finished, and that changes a few things a
+server-rendered app usually takes for granted: the status code, what crawlers
+and caches get, the security policy, and how the page loads. This page goes
+through them, and ends in a checklist.
+
+## Status codes and redirects
+
+The status and headers go out with the shell, before any data has arrived. A
+request that fails later can't turn the response into an error page, and a
+`404` has to be known before the first byte.
+
+- **With the Angular CLI**, `@angular/ssr` keeps its server routes, so give a
+ route its `status` there, and its redirects. A component can still set
+ `RESPONSE_INIT` until the shell goes out: decide the status from the URL, or
+ from a route resolver, whose data is there before the route renders. Anything
+ that arrives with a chunk comes too late. See
+ [What `@angular/ssr` still does](../getting-started/angular-cli.md#what-angularssr-still-does).
+- **On the other setups** every page is a `200`, a not-found page included.
+ A server that knows its routes sets the status from outside, keeping the
+ streamed body, as [the demo's Worker](../../../../cloudflare-demo/src/worker.ts)
+ does:
+
+ ```ts
+ const response = await pages.fetch(request, env);
+ if (isPage(url.pathname) || !response.ok) {
+ return response;
+ }
+ return new Response(response.body, { status: 404, headers: response.headers });
+ ```
+
+ Redirects are the same: answer them before the request reaches the handler.
+
+A page that loads and then finds out its data doesn't exist, a product that was
+deleted, still answers `200`. Show a not-found state in the block, and keep
+such pages out of search with `` set in
+the shell, if the route can tell by then.
+
+## Crawlers and metadata
+
+Crawlers get the same stream as everyone. One that runs scripts, as Google's
+does, sees the page as a reader does, once the stream has ended. One that
+doesn't keeps the shell: each block's loading state, with the streamed markup
+in `` elements at the end of the document, which isn't part of the
+rendered page. There is no buffered render that includes the blocks either:
+the fallback leaves them to the browser too. Whatever must be read without
+scripts belongs in the shell.
+
+The document's `` is part of the shell, so the same goes for metadata:
+
+- **A title or a meta tag set before the shell goes out is in the server's
+ HTML**: one set from the URL, from route data, or in a resolver.
+- **One set from data that streams in later is set in the browser only.**
+ The server's HTML keeps whatever it had, so a crawler that doesn't run
+ scripts, and a link preview, see that.
+
+So set a page's title, description and `og:*` tags from something the route
+knows when it renders. A resolver that loads them holds the shell back for
+that one request, which is the trade: everything else still streams.
+
+## Content Security Policy
+
+The packages put inline scripts in the page: the runtime at the end of the
+shell, and one per chunk, with a `