LoginSignup
5
5

More than 5 years have passed since last update.

Prefetch

Posted at

Prefetch

Prebrowsing シリーズ

次に表示するリソースが、高い確度でわかっている場合は、 prefetch という手段がある。

しかし、 prefetch の並列度(ff は一度に一つ、 chrome は 10 並列)や、走るタイミング(firefox は onload 後、chrome/opera は現在のページを取得中でも TCP を奪ってまでやる。)など仕様が若干曖昧なところがある。

API

<link rel="prefetch" href="http://example.com/">

キャンセル時

prefetch 中に画面遷移すると、 prefetch はキャンセルされる。すると遷移(遷移のために)にもう一度やらないといけない。

この無駄を減らすには、 "Accept-Ranges: bytes" ヘッダが考えられる。

ブラウザが途中からの取得を可能にする。

steve 御大いわく

It's best to prefetch the most important resources in the page: scripts, stylesheets, and fonts. Only prefetch resources that are cacheable - which means that you probably should avoid prefetching HTML responses.
ベストなのは、 prefetch は重要なリソース(js, css, font etc)のみに行う。
キャンセル可能なもののみ行う。つまり HTML にはやらない。

5
5
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5