Cache APIの遅さの原因を調べる
awaitの連鎖の合間に別の処理が割り込んでしてしまっているのが遅さの原因?
https://gyazo.com/4330e7e1ba92b066786131bc11bdc3d2
2秒以上responseに時間がかかっていることもざらにあった
cache apiもfetch apiも同じくらい遅い
Chromeだと早い
https://gyazo.com/19797597ba86aae3f3e7b1add887d018
Firefox
https://gyazo.com/d901845a30e92802ea66da540cb66e85
これはchromeと似たりよったりか
若干遅いかも
https://gyazo.com/148f37653a91d6f6bea484b484013ee2
急にcacheが遅くなっている
なぜ……
https://gyazo.com/f8624b5ee53ea84a61c490e2fa21e8b0
一つのresponseのCache取得で18秒かかっているのはやばすぎ
code:js
{
match_old = Cache.prototype.match;
Cache.prototype.match=async function() {
const url = new URL(arguments0 instanceof Request ? arguments0.url : arguments0, location.href); const tag = Cache ${decodeURIComponent(url.pathname)};
console.time(tag);
const result =await match_old.apply(this,arguments);
console.timeEnd(tag);
return result;
};
fetch_old = globalThis.fetch;
globalThis.fetch = async function() {
const url = new URL(arguments0 instanceof Request ? arguments0.url : arguments0, location.href); const tag = Fetch ${decodeURIComponent(url.pathname)};
console.time(tag);
const result =await fetch_old.apply(this,arguments);
console.timeEnd(tag);
return result;
};
}