GioJSdocs
On this page

[prefetch]

Per-client budgets for the prefetch requests <GioLink> sends, and the site-wide switch for prefetching.

gio.toml
[prefetch]
max_concurrent = 5
max_per_second = 20

Which links prefetch, and when, is chosen per link with <GioLink prefetch>. This section bounds what one client's prefetches may cost the server.

Reference

KeyDefaultDescription
enabledbooleantrueAnswer prefetch requests. false refuses each one with 429 before anything renders, which turns prefetching off site-wide: links still navigate, they just load on click.0 / false / empty: Every prefetch is answered 429
max_concurrentinteger5Prefetches one client may have in flight at once. Past it the server answers 429, which the client treats as "not prefetched".0 / false / empty: Unlimited
max_per_secondinteger20Prefetches one client may start per second.0 / false / empty: Unlimited

Behavior

  • A request is a prefetch when it carries Purpose: prefetch or Sec-Purpose: prefetch, parameters included: a browser's speculation-rules prerender sends Sec-Purpose: prefetch;prerender. Everything else is never counted.
  • A client is its IP address after [server] trusted_proxies resolution. Clients idle for a minute are forgotten.
  • An over-budget prefetch is logged at warn (prefetch budget exceeded); one refused because prefetching is off is not. Both count in the metrics.
  • A slot is released when its response is ready or when the client gives up, so cancelled prefetches never use up the budget.
  • An admitted prefetch is an ordinary request: a page with revalidate is served from the page cache and stored in it like any other GET, with the same Cache-Control: prefetching a cached page costs no render, and a prefetch can fill the cache for the next visitor.

No key in this section logs a startup warning, 0 included.

Examples

Turn prefetching off

gio.toml
[prefetch]
enabled = false
gio.toml
[prefetch]
max_concurrent = 10
max_per_second = 50

Good to know

  • 0 lifts a budget; it does not refuse prefetches. Use enabled = false for that.
  • [prefetch] strategy from earlier docs is refused with a hint: the strategy is chosen per link (<GioLink prefetch="hover" | "viewport" | {false}>).

Version history

VersionChanges
v0.1.0-beta.8Introduced as a gio.toml section with enabled, max_concurrent and max_per_second; 0 means unlimited. strategy is rejected. Sec-Purpose: prefetch;prerender and other parameterized values count as prefetches.
v0.1.0-beta.1Fixed per-client prefetch budgets (5 in flight, 20 per second).