Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document turbo-prefetch meta tags #174

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

seanpdoyle
Copy link
Contributor

  • <meta name="turbo-prefetch" content="false"> will opt-out of InstantClick prefetching for the entire page.

  • <meta name="turbo-prefetch-cache-time" content="15000"> configures the time to live in milliseconds for an entry in the InstantClick prefetch cache. When omitted, the default value is 10 seconds.

* `<meta name="turbo-prefetch" content="false">` will opt-out of
  InstantClick prefetching for the entire page.

* `<meta name="turbo-prefetch-cache-time" content="15000">` configures
  the time to live in milliseconds for an entry in the InstantClick
  prefetch cache. When omitted, the default value is 10 seconds.

Co-authored-by: Steve Polito <[email protected]>
Co-authored-by: Stefanni Brasil <[email protected]>
@@ -43,3 +43,5 @@ The following `meta` elements, added to the `head`, can be used to customize cac
* `<meta name="view-transition" content="same-origin">` to trigger view transitions on browsers that support the [View Transition API](https://caniuse.com/view-transitions).
* `<meta name="turbo-refresh-method" content="morph">` will configure [page refreshes with morphing](/handbook/page_refreshes.html).
* `<meta name="turbo-refresh-scroll" content="preserve">` will enable [scroll preservation during page refreshes](/handbook/page_refreshes.html).
* `<meta name="turbo-prefetch" content="false">` will [opt-out of InstantClick prefetching](/handbook/drive#instantclick) for the entire page.
* `<meta name="turbo-prefetch-cache-time" content="15000">` configures the time to live in milliseconds for an entry in the InstantClick prefetch cache. When omitted, the default value is 10 seconds.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does entry refer to here in this case? The InstaClick entries for the current page?

If I change this value, does the cache limit change for all the already cached entries, or just the new ones in the current page?

To avoid prefetching links that the user is briefly hovering, Turbo waits 100ms after the user hovers over the link before prefetching it. But you may want to disable the prefetching behavior on certain links leading to pages with expensive rendering.
To avoid prefetching links that the user is briefly hovering, Turbo waits 100 milliseconds after the user hovers over the link before prefetching it. But you may want to disable the prefetching behavior on certain links leading to pages with expensive rendering.

By default Turbo will cache requests for 10 seconds. Once that 10 seconds has passed, the value will expire, be cleared from the cache, and a new request will be issued on the next hover.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We remove the entry from the cache when the mouse moves away from the link. The 10 seconds TTL is in case you hover the link for more than 10 seconds and then click it. In that case we issue a new request, instead of using the cached one.

Thinking more about it, I don't think the 10 seconds TTL needs to be configured.

What do you think @seanpdoyle ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants