Posted 鎿庡垱澶忔礇鍏婣IOps
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了相关的知识,希望对你有一定的参考价值。
浠婂ぉ鍚煈嗗摜璇达紙鍚癸級鍒颁粬浠綉绔欑敤HTTP2鎺ㄩ€佹帴鍙h姹傛瀬澶х殑鍔犲揩鐨勭綉绔欒闂€熷害銆傚叾瀹炴垜鍦ㄥ幓骞寸爺绌?HTTP2_push 鏃跺氨鎯冲埌浜嗚繖涓儏褰€?/p>
鏄惁闇€瑕?push 闈欐€佽祫婧愭槸鏈夌枒闂殑锛氱敱浜庣紦瀛樼殑瀛樺湪锛屼綘涓嶈兘纭繚瀹㈡埛绔湡鐨勯渶瑕佽繖涓枃浠躲€傝櫧鐒舵祻瑙堝櫒鍙互涓诲姩闃绘 PUSH 甯х殑鍙戦€侊紝浣嗘槸瀵逛簬宸插彂鍑虹殑甯ф棤鑳戒负鍔涖€?/p>
鎺ュ彛璇锋眰灏变笉瀛樺湪杩欎釜鎯呭喌锛氬洜涓哄畠浠兘涓嶄細琚紙琚紑鍙戣€呯鎺変簡锛夋祻瑙堝櫒缂撳瓨锛屾瘡娆℃墦寮€椤甸潰閮介渶瑕侀噸鏂板姞杞姐€傛墍浠ユ帹閫佹帴鍙h姹傛€绘槸姝g‘鐨勯€夋嫨銆?/p>
Nginx 1.13.9 灏卞鍔犱簡 HTTP2_Push 鏀寔銆侼ginx 寮€鍚?HTTP2 鎺ㄩ€佹湁涓ょ鏂规硶銆?/p>
http2_push 鎸囦护
寮哄埗鎺ㄩ€佹煇 URL銆傜敤娉曞氨鏄細
http2_push URL;
浠ョ湅鍒帮紝瀵逛簬鏈嶅姟绔帹閫佺殑甯э紝娴忚鍣ㄤ細绛夊埌瀹為檯鏈夎姹傛椂鍐嶅幓瑙f瀽銆?/p>
http2_push_preload 鎸囦护
Nginx 浼氳В鏋愰鍔犺浇 Link 澶村姩鎬佺殑鎺ㄩ€佹煇 URL銆傜敤娉曚负锛?/p>
http2_push_preload on;add_header Link "<URL>; rel=preload; as=TYPE; [crossorigin]";
add_header Link "</restapi/shopping/v1/cities>; rel=preload; as=fetch; crossorigin";
杩欐牱鐨勮瘽锛孨ginx 鍚屾牱浼氭帹閫佽繖涓?API 璧勬簮銆備笉鍚岀殑鏄紝娴忚鍣ㄧ敱浜庢敹鍒颁簡 preload_link
澶达紝鍚屾椂浼氶鍔犺浇杩欎釜璧勬簮銆?/p>
鐪嬪埌锛屽浜庢湇鍔$鎺ㄩ€佺殑甯э紝娴忚鍣ㄤ細鍦ㄦ帴鏀跺畬姣曞悗绔嬪嵆瑙f瀽
鑷充簬鍝鎯呭喌鏇村ソ锛屽悇浣嶈鑰呰嚜宸卞彇鑸嶃€?/p>
瀹?/span>
绀轰緥涓敤鍒扮殑浠g爜
setTimeout(() => { const xhr = new XMLHttpRequest();
xhr.responseType = 'json';
xhr.onload = e => { console.log(xhr.response); document.querySelector('pre').textContent = JSON.stringify(xhr.response, null, 2);
};
xhr.open('GET', '/restapi/shopping/v1/cities');
xhr.send();
}, 1000);
鍙傝€冮摼鎺ワ細
https://bugs.chromium.org/p/c...
https://developer.mozilla.org...
https://w3c.github.io/preload/
https://jakearchibald.com/201...
PS锛歨ttp2_push_preload 鐨勬洿楂樼鐢ㄦ硶鍙兘鏄娇鐢?nbsp;njs 鎴?nbsp;openresty 鍔ㄦ€佹坊鍔?Link 澶村疄鐜板姩鎬佹帹閫佽祫婧愶紙渚嬪鏍规嵁涓嶅悓鐨勭敤鎴锋帹閫佷笉鍚岃祫婧愶級
PS2锛氬鏋滀娇鐢?Link 澶存帹閫?API 璧勬簮锛屼竴瀹氳娣诲姞 crossorigin
鍙傛暟锛屽惁鍒欐祻瑙堝櫒涓嶄細浣跨敤鏀跺埌鐨?PUSH 鏁版嵁
PS3锛氱粡娴嬭瘯灏辩畻鍔犱簡 crossorigin
澶?Chrome 涔熶笉涓€瀹氫細鐢ㄦ敹鍒扮殑 PUSH 鏁版嵁锛堣€?Firefox 浼氾紝鍙兘鏄?bug锛夛紝浣跨敤 http2_push
鏄渶淇濋櫓鐨勬柟寮?/p>
澶忔礇鍏?AIOps
Make Data Think
浜哄伐鏅鸿兘 | 鏈哄櫒瀛︿範 | IT杩愮淮
以上是关于的主要内容,如果未能解决你的问题,请参考以下文章