[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 = 20Which links prefetch, and when, is chosen per link with <GioLink prefetch>. This section bounds what one client's prefetches may cost the server.
Reference
| Key | Default | Description |
|---|---|---|
enabledboolean | true | Answer 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. |
max_concurrentinteger | 5 | Prefetches one client may have in flight at once. Past it the server answers 429, which the client treats as "not prefetched". |
max_per_secondinteger | 20 | Prefetches one client may start per second. |
Behavior
- A request is a prefetch when it carries
Purpose: prefetchorSec-Purpose: prefetch, parameters included: a browser's speculation-rules prerender sendsSec-Purpose: prefetch;prerender. Everything else is never counted. - A client is its IP address after
[server] trusted_proxiesresolution. 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
revalidateis served from the page cache and stored in it like any otherGET, with the sameCache-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 = falseA docs site with many viewport links
gio.toml
[prefetch]
max_concurrent = 10
max_per_second = 50Good to know
0lifts a budget; it does not refuse prefetches. Useenabled = falsefor that.[prefetch] strategyfrom earlier docs is refused with a hint: the strategy is chosen per link (<GioLink prefetch="hover" | "viewport" | {false}>).
Related
Version history
| Version | Changes |
|---|---|
v0.1.0-beta.8 | Introduced 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.1 | Fixed per-client prefetch budgets (5 in flight, 20 per second). |