Skip to main content

Routes Configuration

The [routes] section defines which URL paths PRISM should render and which it should skip (proxy directly to origin).

TOML Example​

[routes]
include = ["/**"]
exclude = [
"/api/**",
"/graphql",
"**/*.js",
"**/*.css",
"**/*.json",
"**/*.xml",
"**/*.png",
"**/*.jpg",
"**/*.gif",
"**/*.svg",
"**/*.ico",
"**/*.woff",
"**/*.woff2",
"**/*.ttf",
"**/*.wasm",
"**/*.map",
"/_next/**",
"/static/**",
"/admin/**",
"/robots.txt",
"/.well-known/**",
"**/*.txt",
"**/*.pdf",
"**/*.jpeg",
"**/*.webp",
"**/*.avif",
"**/*.otf",
"**/*.eot",
"**/*.mp4",
"**/*.webm",
"**/*.mp3",
"**/*.zip",
"**/*.gz",
"**/*.webmanifest",
]

Parameters​

ParameterTypeDefaultDescription
includeArray of Strings["/**"]Glob patterns for paths eligible for rendering
excludeArray of Strings(see above)Glob patterns for paths to skip rendering

Glob Matching​

PRISM uses standard glob syntax for route patterns:

PatternMatches
/**All paths
/blog/**/blog/post-1, /blog/2024/my-post, etc.
**/*.jsAny path ending in .js at any depth
/api/**/api/users, /api/v2/products, etc.
/exact-pathOnly /exact-path (no wildcards)

How paths are matched​

Rules are matched against the path as the origin will read it, so the spelling a client chooses cannot change the decision. Before matching, PRISM decodes percent-escapes and collapses runs of slashes: //api/users is excluded wherever /api/** is, and a sloppy link such as //products/x is rendered or not exactly as /products/x would be. A path that contains a . or .. segment or a backslash (written literally or percent-encoded), an invalid escape or a control character is never rendered: stacks disagree about how to read those, no crawler writes them, and the client receives the origin's own answer.

[[cache.rules]] patterns use the same form. The request itself is proxied to the origin exactly as the client sent it, and an ordinary path is its own canonical form, so existing rules and cache entries are unaffected.

Precedence​

Exclude takes precedence over include. If a path matches both an include and an exclude pattern, it is excluded from rendering and proxied directly to the origin.

The evaluation logic is:

  1. Check if the path matches any include pattern
  2. Check if the path matches any exclude pattern
  3. If both match, the path is excluded
  4. If only include matches, the path is rendered
  5. If neither matches, the path is proxied (not rendered)

Detailed Explanation​

Default exclude list​

The default exclude list covers common static assets, API endpoints, and framework-specific paths that never need rendering:

  • API routes: /api/**, /graphql -- backend endpoints return JSON, not HTML
  • Static assets: **/*.js, **/*.css, **/*.json, **/*.xml -- not HTML pages
  • Images: **/*.png, **/*.jpg, **/*.gif, **/*.svg, **/*.ico
  • Fonts: **/*.woff, **/*.woff2, **/*.ttf
  • Other: **/*.wasm, **/*.map -- WebAssembly and source maps
  • Framework paths: /_next/** (Next.js internals), /static/**, /admin/**
  • Crawler and site metadata: /robots.txt, /.well-known/**, **/*.txt, **/*.webmanifest
  • More images, fonts, media and downloads: **/*.jpeg, **/*.webp, **/*.avif, **/*.otf, **/*.eot, **/*.mp4, **/*.webm, **/*.mp3, **/*.pdf, **/*.zip, **/*.gz

The last two groups were added in 1.4.7. exclude replaces the default list, it does not add to it — a configuration that sets exclude (including one that started from the example file of an earlier release) has only what it lists. Compare yours against the list above.

Why excluding non-HTML matters​

A request PRISM decides to render and then finds is not HTML is passed through to the origin, so the answer is the same either way. The cost is not:

  • A crawler's request takes a Chrome tab, is navigated, is found to be an image or a PDF, and is then fetched from the origin a second time. Nothing about that is cached, so it happens on every request.
  • It queues behind the circuit breaker, the rate limits and the tab pool, so while rendering is degraded the asset is answered 503 or 429.
  • A visitor's response for the same URL is marked Vary: User-Agent, because the route renders for bots. That stops most CDNs caching the asset.

Excluding the path avoids all three: it is proxied directly for everyone.

/robots.txt is never rendered​

This one does not depend on exclude. /robots.txt is proxied to the origin whatever the configured routes say — including include = ["/robots.txt"].

The Robots Exclusion Protocol fixes both its location and its format (plain text), so there is no configuration in which rendering it means anything; and a crawler that receives a 5xx or 429 for it stops crawling the site. Before 1.4.7 the default list did not exclude it, so that is what a crawler received whenever rendering was unavailable or the render budget was spent.

Custom include patterns​

The default ["/**"] includes all paths. Narrow this to only render specific sections:

[routes]
include = ["/blog/**", "/products/**", "/"]
exclude = []

Example Use Cases​

Only render marketing pages​

[routes]
include = ["/", "/features", "/pricing", "/blog/**", "/about"]
exclude = []

Render everything except admin and API​

[routes]
include = ["/**"]
exclude = ["/api/**", "/graphql", "/admin/**", "/dashboard/**"]

Next.js application​

[routes]
include = ["/**"]
exclude = [
"/api/**",
"/_next/**",
"/static/**",
"**/*.js",
"**/*.css",
"**/*.json",
"**/*.png",
"**/*.jpg",
"**/*.svg",
"**/*.ico",
"**/*.woff2",
]