Skip to main content

Render Configuration

The [render] section controls how PRISM renders pages using a headless Chromium browser. It includes sub-sections for the browser tab pool, circuit breaker, HTML postprocessing, viewport emulation, and content validation.

TOML Example​

[render]
wait_for = "load"
timeout_secs = 10
block_resources = ["font", "image", "media", "stylesheet"]
status_from_meta = true
fail_on_console_errors = false
min_html_size = 512
post_wait_js = "document.querySelector('.lazy')?.classList.remove('hidden')"

[render.pool]
tabs = 8
max_renders_per_tab = 50
queue_max = 100
queue_timeout_secs = 45

[render.circuit_breaker]
failure_threshold = 5
recovery_timeout_secs = 30
half_open_max_requests = 1

[render.postprocess]
enabled = true
strip_scripts = true
strip_noscript = true
strip_comments = true
strip_event_handlers = true
strip_hydration_attrs = true
resolve_lazy_images = true

[render.viewport]
enabled = false
mobile_width = 412
mobile_height = 915
desktop_width = 1920
desktop_height = 1080

[render.content_validation]
enabled = true
min_text_length = 100
require_title = true
min_html_bytes = 1024

Top-Level Parameters​

ParameterTypeDefaultDescription
wait_forString"load"Page readiness signal: load, domcontentloaded, networkidle, domidle, or selector:<CSS>
dom_idle_initial_delay_msInteger1000domidle and networkidle: how long after the page loaded to look for loading indicators the first time. At most 10000. See Tuning the waits
dom_idle_settle_msInteger300domidle and networkidle: how long to wait once no loading indicator is left. At most 10000
network_quiet_msInteger500networkidle: how long no request may be in flight, continuously, before the network counts as quiet. Also the quiet window after auto-scroll. At most 5000
timeout_secsInteger10Maximum seconds to wait for a page render. Time spent waiting for a free tab is not included; see pool.queue_timeout_secs. Must be > 0
block_resourcesArray of Strings["font", "image", "media", "stylesheet"]Resource types to block during rendering
status_from_metaBooleantrueTake the HTTP status from a <meta> tag named prism:status, render:status_code or prerender-status-code, or from window.__PRISM_STATUS__
fail_on_console_errorsBooleanfalseFall back to origin if JS console errors detected and HTML is below min_html_size
min_html_sizeInteger512Minimum rendered HTML bytes; below this with console errors triggers fallback
incomplete_ttl_secsInteger or unsetunsetHow long, at most, to keep a render that was extracted before the page finished. Unset stores it like any other render; 0 serves it once and stores nothing. See incomplete_ttl_secs
post_wait_jsString or nullnullJavaScript to execute after the wait and the scroll complete but before HTML extraction
auto_scrollBooleantrueScroll the page after the wait, so intersection observers fire and lazy-loaded content is present. See auto_scroll
auto_scroll_step_pxInteger400How far each scroll step moves down the page. Must be > 0
auto_scroll_step_delay_msInteger100Pause after each scroll step, for intersection observers to fire. At most 5000
bypass_cspBooleanfalseDisable origin Content-Security-Policy during rendering; normally leave disabled
max_html_bytesInteger33554432 (32 MiB)Maximum rendered HTML size; larger documents are rejected
max_dom_nodesInteger400000Maximum DOM element count before serialization; 0 disables the bound
accept_invalid_certsBooleanfalseLet Chrome render pages whose TLS certificate does not validate. See accept_invalid_certs
devtools_transportString"pipe"How PRISM controls Chrome: "pipe" opens no DevTools port, "port" uses Chrome's loopback TCP port. See devtools_transport
browserString"chromium"Which Chrome build renders: "chromium", the full browser, or "headless-shell", the faster headless-only build. See browser
chrome_disable_featuresArray[]Chrome features to switch off on top of the browser interface PRISM always switches off. See chrome_disable_features

wait_for​

Controls when PRISM considers the page "ready" to extract HTML:

  • load (default): Waits for the browser load event plus a small (~100 ms) settle window. A real readiness signal — fires after the document and all sub-resources finish loading — but it does not wait for client-side fetches that hydrate the SPA after page load. Good for static-ish SPAs where the meaningful content is server-rendered or already in the bundle.
  • domcontentloaded: Fires when the HTML is parsed, before sub-resources finish. Faster than load, almost always too early for hydration-heavy SPAs.
  • networkidle: First waits for the page to stop showing loading indicators (the same check as domidle), then waits for the network to go quiet: no request in flight, continuously, for 500 ms. Catches XHR/fetch hydration. The network wait is capped at 5 seconds and never runs past timeout_secs. A page that is still busy after that is rendered anyway but counted as incomplete with reason network. Event streams (EventSource) and WebSockets are not counted, since they never finish. A page that keeps even one request open permanently (a long poll, a chatty beacon) therefore always waits the full five seconds and is always marked incomplete. Such a site should use selector: or domidle.
  • domidle: What networkidle did before PRISM looked at the network. Polls the DOM for elements whose class contains shimmer, loading, skeleton or spinner, and for the word "Loading" in the page text, and stops when none is left (or after ten seconds). It never looks at requests. For operators who need the old behaviour.
  • selector:<CSS>: Waits until a CSS selector appears in the DOM. Example: selector:#app-loaded or selector:[data-hydrated="true"]. Recommended for production — the SPA explicitly tells PRISM when it is ready, so render time is bounded by your app's actual hydration, not by a network heuristic. If the selector has not appeared after ten seconds, or timeout_secs runs out first, the render continues but is counted as incomplete with reason selector (or timeout).

A wait that is cut off by timeout_secs is counted as incomplete with reason timeout.

Tuning the waits​

networkidle and domidle spend fixed time on every render, whatever the page does:

StepSettingDefault
Before the first look for loading indicatorsdom_idle_initial_delay_ms1000 ms
After the last indicator is gonedom_idle_settle_ms300 ms
Network quiet, continuously (networkidle only)network_quiet_ms500 ms

The network window counts back from the last request, so it often overlaps the DOM steps. With the defaults a networkidle render therefore spends at least 1.3 seconds after the page has loaded, and more while requests are still running. A light SPA page took about 1.7 seconds in total, and with a fixed number of tabs that time bounds how many renders per second a replica can do (see Capacity Planning).

The initial delay exists for frameworks that paint their loading skeleton late: if PRISM looks before the skeleton exists, it sees no indicator and moves on. The network wait that follows catches the data fetches themselves, so a site whose skeleton appears straight away, or whose data arrives by fetch, can shorten it. Shorten one setting at a time and compare the rendered HTML of the pages that matter (category, product, search) before and after: purge each URL with POST /purge/url on the admin API, then request it through PRISM as a crawler, for example curl -A "Googlebot/2.1" (see Upgrading to 1.5.0). A render that is now taken too early shows as a loading skeleton or missing data in that HTML; a network wait that is now too short shows in prism_render_incomplete_total{reason="network"} only when it runs out, not when it ends too soon, so the HTML is the check.

Lengthen network_quiet_ms for a site that fetches in a chain with gaps between the requests: each gap longer than the window ends the wait early.

:::tip Production recommendation For sites where SEO matters, add an app-ready marker to your SPA root component (e.g. <div id="root" data-app-ready="true"> once your data is loaded) and set wait_for = "selector:[data-app-ready]". This eliminates "rendered too early — hero JSON missing" failures that are otherwise hard to diagnose because they only happen under load. :::

status_from_meta​

On by default. PRISM scans the rendered HTML for a meta tag such as:

<meta name="prism:status" content="404">

This lets SPAs that render 404 pages client-side communicate the correct HTTP status code to crawlers, instead of the unknown route being cached as a 200. Set status_from_meta = false to ignore the tag and window.__PRISM_STATUS__ and always use the origin's status. Tag names, what is ignored and the accepted values are in Status Codes.

incomplete_ttl_secs​

A render is incomplete when PRISM extracted it before the page finished: the selector: never appeared (selector), the network did not go quiet within the networkidle allowance (network), or the wait was cut off by timeout_secs (timeout). PRISM still serves it, logs a WARN naming the URL and the reason, and counts it in prism_render_incomplete_total{reason}.

By default an incomplete render is cached like any other, for the full TTL. That can leave a half-rendered page, such as a skeleton or an error view, in front of crawlers for an hour. Set incomplete_ttl_secs to bound it:

[render]
incomplete_ttl_secs = 60 # keep an unfinished page for at most a minute
# incomplete_ttl_secs = 0 # never store one
  • Unset (default): stored for the TTL it would normally have.
  • A number above 0: stored for at most that many seconds — the smaller of this and the TTL it would have had. The Cache-Control sent to clients carries the shorter lifetime.
  • 0: served to the request that triggered it and not stored. When a background refresh of a stale entry comes back incomplete and would not be stored, the existing entry stays in place.

Rendering load or domcontentloaded is never incomplete for network reasons, because those modes do not wait on the network.

PRISM can only cap a render it knows is incomplete. With load, domcontentloaded or domidle it has little to go on, so a page that is still a skeleton can be stored as complete. Where a half-rendered page must not reach the cache, such as product and category pages, use a selector: wait on a marker your application sets when its data has loaded, together with incomplete_ttl_secs = 0. A page that never reaches the marker is then rendered again on every request, so watch prism_render_incomplete_total.

The setting covers what PRISM stores and the Cache-Control PRISM writes itself. It does not replace a Cache-Control your origin sent. PRISM passes that header on unchanged, so a CDN that honours an origin's public, max-age=… can keep an incomplete render that PRISM did not store. See CDN Integration.

post_wait_js​

Optional JavaScript executed after the wait and the scroll are complete but before HTML is extracted. Useful for DOM fixups on SPAs with lazy hydration, such as removing hidden classes that a framework has not yet removed.

auto_scroll​

Many SPAs only populate a product grid once it scrolls into view, so without this pass they serialise empty. After the wait_for condition is met, PRISM scrolls the page in steps of auto_scroll_step_px (400) and pauses auto_scroll_step_delay_ms (100 ms) after each, bounded to roughly five seconds and 200 steps. A 3000-pixel page therefore spends about 800 ms scrolling. If the scroll starts any network request, PRISM then waits up to three more seconds for the requests the scroll started to finish, and for none of them to be in flight for network_quiet_ms (500 ms). Requests that were already in flight before the scroll, such as a long poll, do not hold this wait. A page whose scroll starts nothing pays nothing extra, and requests that are still running after those three seconds do not make the render incomplete.

The cost is that on a tall page it spends that entire budget on every render. A site that hydrates everything up front gains nothing and should turn it off:

[render]
auto_scroll = false

Leave it on if any part of the site lazy-loads content on scroll — turning it off there produces rendered pages with empty sections, which is worse than a slow render.

Between the two, a larger step and a shorter pause make the pass cheaper while keeping it. A step about as tall as the viewport (viewport settings) still brings every part of the page into view once; a pause shorter than the time the site's observers take to start their requests misses them. Check the lazy sections in the rendered HTML after changing either: purge the URL with POST /purge/url and request it as a crawler.

accept_invalid_certs​

Off by default: Chrome refuses expired, self-signed and hostname-mismatched certificates, on the origin and on every subresource a page pulls in.

:::danger This weakens a real boundary PRISM renders attacker-influenced content and then caches the result and serves it to crawlers as your site's own. Accepting a bad certificate lets anyone on the network path substitute a page or a subresource and have PRISM publish it under your name, with no TLS warning anywhere because nothing is listening for one. :::

Turn it on only for an internal origin whose certificate you control and have deliberately not had signed — and prefer adding your CA to the trust store instead:

[render]
accept_invalid_certs = true

devtools_transport​

How PRISM controls Chrome. There are two values, and any other value is a configuration error.

  • "pipe" (the default): Chrome is started with --remote-debugging-pipe and exchanges DevTools messages with PRISM over a pair of pipes. No DevTools port exists, on any interface.
  • "port": Chrome is started with --remote-debugging-port=0 and opens an unauthenticated TCP port on the loopback interface. This is how PRISM worked before the pipe transport existed.

chromiumoxide, the library PRISM uses to drive Chrome, only speaks WebSocket. To use pipes, PRISM starts a copy of its own executable in place of Chrome. That copy starts the real browser on the pipes, accepts one WebSocket connection from PRISM, authenticated by a random token in the URL, and then closes its listening socket. It runs only for that purpose and does not read your configuration. If it is killed, Chrome is killed with it.

PRISM finds the browser as it always has: the CHROME environment variable, then CHROME_PATH when it names an existing file, then a search for a Chrome or Chromium executable. If PRISM cannot find the browser, or cannot find its own executable (for example because the file was replaced while PRISM was running), it logs a warning that says why and uses "port" for that launch, so the site keeps rendering.

Use "port" only if the pipe transport does not work in your environment, and see Chrome's DevTools port for what that costs.

[render]
devtools_transport = "port"

chrome_disable_features​

Every render runs in a browser context of its own, so that no cookie, storage or cache entry from one render can reach the next. Chrome opens a window for each context, and recent versions build parts of the browser interface for every window even when running headless. In Chromium 156 that was the address bar's suggestion popup and its AI Mode variant: two internal pages, each in a renderer process of its own, for every render. Nobody ever sees them, so PRISM always switches them off (WebUIOmniboxPopup, WebUIOmniboxAimPopup, WebUIOmniboxFullPopup). It also switches off SpareRendererForSitePerProcess: Chrome keeps a renderer process started for the next page, but a spare belongs to one context and every render gets a new one, so it was started and thrown away each time. On a 4-CPU box rendering sixteen pages at a time, the two together took the same storefront from 5.0 to 10.6 renders per second and halved Chrome's memory.

chrome_disable_features adds to that list, for when a Chrome update brings more such interface before a PRISM release does. Use the names Chrome uses for its features; a name this Chrome does not know is ignored. Only letters, digits and underscores are accepted, and the setting can switch features off, nothing else: it cannot turn off the sandbox, the egress proxy or the DevTools transport. The features behind site isolation (SitePerProcess, IsolateOrigins, IsolateSandboxedIframes, OriginKeyedProcessesByDefault) are refused at start-up: rendered pages are untrusted, and site isolation keeps a cross-site frame on one in a process of its own. Switching it off did not make rendering faster.

[render]
chrome_disable_features = ["BackForwardCache"]

browser​

Which Chrome build renders the pages.

  • "chromium" (the default): the full Chromium or Chrome, in its headless mode (--headless=new). It is the same browser people run, with its windows and interface built and never shown.
  • "headless-shell": the separate headless-only build, Debian's chromium-headless-shell or Chrome for Testing's chrome-headless-shell. It has no windows and no browser interface, so the browser context PRISM opens for every render costs it next to nothing. On a 4-CPU box rendering sixteen pages at a time, the same storefront went from about 11 to 21 renders per second with it, with p95 latency under a second; one render at a time was about 7% faster.

The shell is the same Chromium engine and release, and renders pages the same way; what it lacks is what a person at a screen would use. Even so, compare the rendered HTML of the pages that matter on both builds before switching a production site; Upgrading to 1.5.0 shows how.

PRISM looks for the shell in this order:

  1. The file named by the CHROME_HEADLESS_SHELL environment variable.
  2. /usr/lib/chromium/chromium-headless-shell and /usr/bin/chromium-headless-shell (Debian's package), then /usr/lib64/chromium-browser/headless_shell (Fedora's chromium-headless).
  3. chrome-headless-shell, then chromium-headless-shell, in each PATH directory.

CHROME_PATH keeps naming the full browser and does not stop the search. If no shell is found, PRISM logs a warning and renders with the full browser, so a missing package costs speed, not rendering. When the shell is in use, PRISM logs rendering with the headless shell with its path at start-up.

The Docker image ships the shell next to the full browser, at the same version, so in a container the setting is all that is needed. On a host, install chromium-headless-shell from the distribution first.

[render]
browser = "headless-shell"

Pool Configuration​

The [render.pool] sub-section controls the Chromium browser tab pool.

ParameterTypeDefaultDescription
tabsInteger8Number of browser tabs to keep open. Must be > 0
max_renders_per_tabInteger50Deprecated and ignored. Each render already gets a fresh BrowserContext that is disposed afterwards, so per-tab recycling has no work left to do. Accepted so existing configs keep loading. Use max_browser_age_secs / max_renders_per_browser
queue_maxInteger100Maximum queued render requests before rejecting new ones
queue_timeout_secsInteger45Maximum seconds a render request waits for a free tab. When it expires the request is refused with a 503 and Retry-After, counted as queue_full in prism_requests_rejected_total, and not retried. Does not count against timeout_secs or the circuit breaker. The default is longer than the longest planned browser recycle (a 35-second drain plus the relaunch), so a request that arrives during one is served, not refused. Must be > 0
max_browser_age_secsInteger3600Recycle the Chrome process once it has been up this long. 0 disables
max_renders_per_browserInteger5000Recycle the Chrome process after this many renders. 0 disables
recycle_at_memory_percentInteger80Recycle the Chrome process when its memory (the browser and all its child processes) reaches this percentage of the limit PRISM runs under: the cgroup limit — a container limit or systemd MemoryMax — or total system memory when there is none. 0 disables. Must be 0–100

Age and render count bound Chrome's memory over hours. recycle_at_memory_percent is what catches a few heavy pages reaching the limit in minutes: without it the kernel settles the matter by killing a process, and a recycle — a few seconds of queued renders — is much the cheaper outcome. A browser is never recycled for memory in its first two minutes, so a pool whose steady state is above the threshold does not recycle continuously; it logs a warning each time instead, and the fix is fewer tabs or a higher limit. Watch prism_chrome_rss_bytes and prism_chrome_recycles_total.

Increasing tabs improves concurrent throughput but uses more memory. Each tab consumes roughly 50-100 MB of RAM depending on page complexity.

Circuit Breaker Configuration​

The [render.circuit_breaker] sub-section implements the circuit breaker pattern to protect against cascading failures when Chromium is unhealthy.

ParameterTypeDefaultDescription
failure_thresholdInteger5Consecutive failures before opening the circuit
recovery_timeout_secsInteger30Seconds to wait before attempting recovery (half-open state)
window_sizeInteger50Sliding failure-window size; 0 selects the consecutive-failure mode
failure_rate_percentInteger50Failure percentage that opens a full sliding window
half_open_max_requestsInteger1Number of test requests allowed in half-open state

When the circuit is open, all render requests immediately fall back to the origin response instead of waiting for Chromium.

When PRISM has replaced Chromium after a crash, an open circuit moves to half-open at once instead of waiting out recovery_timeout_secs, so the next render is the probe. The circuit still closes only after that probe succeeds. A closed or half-open circuit is not affected by a restart.

Postprocess Configuration​

The [render.postprocess] sub-section controls HTML cleanup applied to rendered output before caching and serving.

ParameterTypeDefaultDescription
enabledBooleantrueEnable or disable all postprocessing
strip_scriptsBooleantrueRemove <script> tags from rendered HTML
strip_noscriptBooleantrueRemove <noscript> tags
strip_commentsBooleantrueRemove HTML comments
strip_event_handlersBooleantrueRemove inline event handlers (onclick, onload, etc.)
strip_hydration_attrsBooleantrueRemove framework hydration attributes (data-reactid, ng-*, etc.). Scoped-style attributes (data-v-*, _ngcontent-*, _nghost-*, data-astro-cid-*) are kept
resolve_lazy_imagesBooleantrueMove data-src to src for lazy-loaded images

Postprocessing produces cleaner HTML for search engine crawlers and reduces response size.

Viewport Configuration​

The [render.viewport] sub-section enables viewport emulation for mobile-aware rendering.

ParameterTypeDefaultDescription
enabledBooleanfalseEnable viewport-aware rendering
mobile_widthInteger412Width in pixels for mobile viewport
mobile_heightInteger915Height in pixels for mobile viewport
desktop_widthInteger1920Width in pixels for desktop viewport
desktop_heightInteger1080Height in pixels for desktop viewport

When enabled, PRISM detects the requesting device type and sets the browser viewport accordingly. This ensures responsive SPAs render the correct layout for mobile vs. desktop crawlers (e.g., Googlebot Mobile).

Content Validation Configuration​

The [render.content_validation] sub-section validates rendered output quality before caching and serving.

ParameterTypeDefaultDescription
enabledBooleantrueEnable content validation
min_text_lengthInteger100Minimum visible text characters (after stripping HTML tags)
require_titleBooleantrueRequire a non-empty <title> tag in rendered output
min_html_bytesInteger1024Minimum total HTML size in bytes

Content validation catches broken renders (empty pages, error screens) and prevents them from being cached or served to crawlers.

Example Use Cases​

React SPA with slow hydration​

[render]
wait_for = "selector:#app-ready"
timeout_secs = 15
post_wait_js = "document.querySelectorAll('.skeleton').forEach(el => el.remove())"

[render.pool]
tabs = 12
queue_max = 200

High-traffic site with conservative settings​

[render]
wait_for = "load"
timeout_secs = 8
fail_on_console_errors = true
min_html_size = 1024

[render.circuit_breaker]
failure_threshold = 3
recovery_timeout_secs = 60

[render.content_validation]
enabled = true
min_text_length = 200
min_html_bytes = 2048

Minimal postprocessing for debugging​

[render.postprocess]
enabled = true
strip_scripts = false
strip_comments = false
strip_hydration_attrs = false