Route rules
How a module declares the caching, server rendering and headers of its pages.
A module declares how its pages are rendered and cached, by page pattern, in its dms.server.ts. A pattern is /x, /x/* (one segment below) or /x/** (the page and everything below).
server.registerRouteRules({
"/terms-of-use": { cache: { public: true, maxAge: 300, staleWhileRevalidate: 3600 } },
"/builder/**": { ssr: false },
"/reports/**": { headers: { "x-robots-tag": "noindex" } },
});
| Rule | Effect |
|---|---|
cache | Page documents and Inertia answers default to private, no-cache, because they carry the visitor's session. A public cache replaces that default, with Vary: X-Inertia, Cookie, under narrow conditions. The request is a GET without any cookie and without x-content-language, for a page the backend serves to anyone (publicAccess), and the answer is a 200. Such an answer holds nobody's data. Any other request keeps the private default. cache: false keeps the default under a broader rule. |
ssr: false | A document request gets the client-rendered shell instead of a server render. Inertia visits are unchanged. |
headers | Added to the page's document and Inertia answers. The server sets cache-control, vary, set-cookie, content-type, content-length, x-inertia and x-inertia-version itself. A header among those, an invalid header name, or a value with a control character rejects the whole route rule, with a warning. |
The frontend server stores nothing itself. A public cache rule is for a shared cache or a CDN in front of it.
Merging
The rules that match a page merge from the least to the most specific pattern. For one pattern, the rule of the highest-priority module wins, with a warning. A rule never changes who may see a page, because the backend checks access on every request.