銆屾煡缂鸿ˉ婕忋€嶅珐鍥轰綘鐨凥TTP鐭ヨ瘑浣撶郴
Posted 濂囪垶绮鹃€?/a> 銆屾煡
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了銆屾煡缂鸿ˉ婕忋€嶅珐鍥轰綘鐨凥TTP鐭ヨ瘑浣撶郴相关的知识,希望对你有一定的参考价值。
缂栬€呮寜锛氭湰鏂囨潵鑷?TianTianUP鐨勬帢閲戜笓鏍忥紝鎺堟潈濂囪垶鍛ㄥ垔杞浇銆?/p>
鍓嶈█
杩欐姊崇悊鐨勭瘒骞呬富瑕佹槸娑夊強缃戠粶閮ㄥ垎锛屽寘鎷琀TTP绛夛紝瀵瑰珐鍥鸿嚜宸辩殑缃戠粶鐭ヨ瘑浣撶郴涔熸槸寰堟湁甯姪鐨勶紝杩涗竴姝ョ殑瀵规€ц兘浼樺寲鑰岃█涔熸槸甯姪寰堝ぇ鐨勩€?/p>
浣嗘洿澶氱殑鏄姏鐮栧紩鐜夛紝甯屾湜瀵逛綘浠湁鎵€甯姪銆?/p>
鎰熻阿鎺樺弸鐨勯紦鍔变笌鏀寔馃尮馃尮馃尮锛屽線鏈熸枃绔犻兘鍦ㄦ渶鍚庢⒊鐞嗗嚭鏉ヤ簡(鈼?鈼?鈼?
鎺ヤ笅鏉ュ氨浠ラ棶棰樼殑褰㈠紡灞曞紑姊崇悊馃憞
璋堜竴璋圚TTP鍗忚浼樼己鐐?/h2>
瓒呮枃鏈紶杈撳崗璁紝銆孒TTP 鏄竴涓湪璁$畻鏈轰笘鐣岄噷涓撻棬鍦ㄤ袱鐐逛箣闂翠紶杈撴枃瀛椼€佸浘鐗囥€侀煶棰戙€佽棰戠瓑瓒呮枃鏈暟鎹殑绾﹀畾鍜岃鑼冦€?/strong>銆?/p>
銆岀伒娲诲彲鎵╁睍銆?/strong>銆備竴涓槸璇硶涓婂彧瑙勫畾浜嗗熀鏈牸寮忥紝绌烘牸鍒嗛殧鍗曡瘝锛屾崲琛屽垎闅斿瓧娈电瓑銆傚彟澶栦竴涓氨鏄紶杈撳舰寮忎笂涓嶄粎鍙互浼犺緭鏂囨湰锛岃繕鍙互浼犺緭鍥剧墖锛岃棰戠瓑浠绘剰鏁版嵁銆?/span> 銆岃姹?搴旂瓟妯″紡銆?/strong>锛岄€氬父鑰岃█锛屽氨鏄竴鏂瑰彂閫佹秷鎭紝鍙﹀涓€鏂硅鎺ュ彈娑堟伅锛屾垨鑰呮槸鍋氬嚭鐩稿簲绛夈€?/span> 銆屽彲闈犱紶杈撱€?/strong>锛孒TTP鏄熀浜嶵CP/IP锛屽洜姝ゆ妸杩欎竴鐗规€х户鎵夸簡涓嬫潵銆?/span> 銆屾棤鐘舵€併€?/strong>锛岃繖涓垎鍦烘櫙鍥炵瓟鍗冲彲銆?/span> 銆屾棤鐘舵€併€?/strong>锛屾湁鏃跺€欙紝闇€瑕佷繚瀛樹俊鎭紝姣斿鍍忚喘鐗╃郴缁燂紝闇€瑕佷繚鐣欎笅椤惧淇℃伅绛夌瓑锛屽彟澶栦竴鏂归潰锛屾湁鏃跺€欙紝鏃犵姸鎬佷篃浼氬噺灏戠綉缁滃紑閿€锛屾瘮濡傜被浼肩洿鎾涓氳繖鏍峰瓙绛夛紝杩欎釜杩樻槸鍒嗗満鏅潵璇淬€?/span> 銆屾槑鏂囦紶杈撱€?/strong>锛屽嵆鍗忚閲岀殑鎶ユ枃(涓昏鎸囩殑鏄ご閮?涓嶄娇鐢ㄤ簩杩涘埗鏁版嵁锛岃€屾槸鏂囨湰褰㈠紡銆傝繖璁〩TTP鐨勬姤鏂囦俊鎭毚闇茬粰浜嗗鐣岋紝缁欐敾鍑昏€呭甫鏉ヤ簡渚垮埄銆?/span> 銆岄槦澶撮樆濉炪€?/strong>锛屽綋http寮€鍚暱杩炴帴鏃讹紝鍏辩敤涓€涓猅CP杩炴帴锛屽綋鏌愪釜璇锋眰鏃堕棿杩囬暱鏃讹紝鍏朵粬鐨勮姹傚彧鑳藉浜庨樆濉炵姸鎬侊紝杩欏氨鏄槦澶撮樆濉為棶棰樸€?/span> 1991骞?鍘熷瀷鐗堟湰锛屽姛鑳界畝闄嬶紝鍙湁涓€涓懡浠ET,鍙敮鎸佺函鏂囨湰鍐呭锛岃鐗堟湰宸茶繃鏃躲€?/p> 浠讳綍鏍煎紡鐨勫唴瀹归兘鍙互鍙戦€侊紝杩欎娇寰椾簰鑱旂綉涓嶄粎鍙互浼犺緭鏂囧瓧锛岃繕鑳戒紶杈撳浘鍍忋€佽棰戙€佷簩杩涘埗绛夋枃浠躲€?/span> 闄や簡GET鍛戒护锛岃繕寮曞叆浜哖OST鍛戒护鍜孒EAD鍛戒护銆?/span> http璇锋眰鍜屽洖搴旂殑鏍煎紡鏀瑰彉锛岄櫎浜嗘暟鎹儴鍒嗭紝姣忔閫氫俊閮藉繀椤诲寘鎷ご淇℃伅锛圚TTP header锛夛紝鐢ㄦ潵鎻忚堪涓€浜涘厓鏁版嵁銆?/span> 鍙娇鐢?header 涓殑 If-Modified-Since 鍜?Expires 浣滀负缂撳瓨澶辨晥鐨勬爣鍑嗐€?span class="mq-55">涓嶆敮鎸佹柇鐐圭画浼狅紝涔熷氨鏄锛屾瘡娆¢兘浼氫紶閫佸叏閮ㄧ殑椤甸潰鍜屾暟鎹€?/span> 閫氬父姣忓彴璁$畻鏈哄彧鑳界粦瀹氫竴涓?IP锛屾墍浠ヨ姹傛秷鎭腑鐨?URL 骞舵病鏈変紶閫掍富鏈哄悕锛坔ostname锛?/span> http1.1鏄洰鍓嶆渶涓轰富娴佺殑http鍗忚鐗堟湰锛屼粠1999骞村彂甯冭嚦浠婏紝浠嶆槸涓绘祦鐨刪ttp鍗忚鐗堟湰銆?/p>
寮曞叆浜嗘寔涔呰繛鎺ワ紙 persistent connection锛夛紝鍗砊CP杩炴帴榛樿涓嶅叧闂紝鍙互琚涓姹傚鐢紝涓嶇敤澹版槑Connection: keep-alive銆傞暱杩炴帴鐨勮繛鎺ユ椂闀垮彲浠ラ€氳繃璇锋眰澶翠腑鐨?keep-alive 鏉ヨ缃?/span> 寮曞叆浜嗙閬撴満鍒讹紙 pipelining锛夛紝鍗冲湪鍚屼竴涓猅CP杩炴帴閲岋紝瀹㈡埛绔彲浠ュ悓鏃跺彂閫佸涓?璇锋眰锛岃繘涓€姝ユ敼杩涗簡HTTP鍗忚鐨勬晥鐜囥€?/span> HTTP 1.1 涓柊澧炲姞浜?E-tag锛孖f-Unmodified-Since, If-Match, If-None-Match 绛夌紦瀛樻帶鍒舵爣澶存潵鎺у埗缂撳瓨澶辨晥銆?/span> 鏀寔鏂偣缁紶锛岄€氳繃浣跨敤璇锋眰澶翠腑鐨?Range 鏉ュ疄鐜般€?/span> 鏂板鏂规硶锛歅UT銆?PATCH銆?OPTIONS銆?DELETE銆?/span> 鍦ㄤ紶杈撴暟鎹繃绋嬩腑锛屾墍鏈夊唴瀹归兘鏄槑鏂囷紝瀹㈡埛绔拰鏈嶅姟鍣ㄧ閮芥棤娉曢獙璇佸鏂圭殑韬唤锛屾棤娉曚繚璇佹暟鎹殑瀹夊叏鎬с€?/span> HTTP/1.1 鐗堟湰榛樿鍏佽澶嶇敤TCP杩炴帴锛屼絾鏄湪鍚屼竴涓猅CP杩炴帴閲岋紝鎵€鏈夋暟鎹€氫俊鏄寜娆″簭杩涜鐨勶紝鏈嶅姟鍣ㄩ€氬父鍦ㄥ鐞嗗畬涓€涓洖搴斿悗锛屾墠浼氱户缁幓澶勭悊涓嬩竴涓紝杩欐牱瀛愬氨浼氶€犳垚闃熷ご闃诲銆?/span> http/1.x 鐗堟湰鏀寔Keep-alive锛岀敤姝ゆ柟妗堟潵寮ヨˉ鍒涘缓澶氭杩炴帴浜х敓鐨勫欢杩燂紝浣嗘槸鍚屾牱浼氱粰鏈嶅姟鍣ㄥ甫鏉ュ帇鍔涳紝骞朵笖鐨勮瘽锛屽浜庡崟鏂囦欢琚笉鏂姹傜殑鏈嶅姟锛孠eep-alive浼氭瀬澶у奖鍝嶆€ц兘锛屽洜涓哄畠鍦ㄦ枃浠惰璇锋眰涔嬪悗杩樹繚鎸佷簡涓嶅繀瑕佺殑杩炴帴寰堥暱鏃堕棿銆?/span> 浜岃繘鍒跺垎甯?/span> 杩欐槸涓€娆″交搴曠殑浜岃繘鍒跺崗璁紝澶翠俊鎭拰鏁版嵁浣撻兘鏄簩杩涘埗锛屽苟涓旂粺绉颁负"甯?锛氬ご淇℃伅甯у拰鏁版嵁甯с€?/span> 澶撮儴鍘嬬缉 HTTP 1.1鐗堟湰浼氬嚭鐜?銆孶ser-Agent銆丆ookie銆丄ccept銆丼erver銆丷ange銆?/strong> 绛夊瓧娈靛彲鑳戒細鍗犵敤鍑犵櫨鐢氳嚦鍑犲崈瀛楄妭锛岃€?Body 鍗寸粡甯稿彧鏈夊嚑鍗佸瓧鑺傦紝鎵€浠ュ鑷村ご閮ㄥ亸閲嶃€侶TTP 2.0 浣跨敤 HPACK 绠楁硶杩涜鍘嬬缉銆?/span> 澶氳矾澶嶇敤 澶嶇敤TCP杩炴帴锛屽湪涓€涓繛鎺ラ噷锛屽鎴风鍜屾祻瑙堝櫒閮藉彲浠ュ悓鏃跺彂閫佸涓姹傛垨鍥炲簲锛屼笖涓嶇敤鎸夐『搴忎竴涓€瀵瑰簲锛岃繖鏍峰瓙瑙e喅浜嗛槦澶撮樆濉炵殑闂銆?/span> 鏈嶅姟鍣ㄦ帹閫?/span> 鍏佽鏈嶅姟鍣ㄦ湭缁忚姹傦紝涓诲姩鍚戝鎴风鍙戦€佽祫婧愶紝鍗虫湇鍔″櫒鎺ㄩ€併€?/span> 璇锋眰浼樺厛绾?/span> 鍙互璁剧疆鏁版嵁甯х殑浼樺厛绾э紝璁╂湇鍔$鍏堝鐞嗛噸瑕佽祫婧愶紝浼樺寲鐢ㄦ埛浣撻獙銆?/span> HTTP 1.1鐗堟湰浼氬嚭鐜?銆孶ser-Agent銆丆ookie銆丄ccept銆丼erver銆丷ange銆?/strong> 绛夊瓧娈靛彲鑳戒細鍗犵敤鍑犵櫨鐢氳嚦鍑犲崈瀛楄妭锛岃€?Body 鍗寸粡甯稿彧鏈夊嚑鍗佸瓧鑺傦紝鎵€浠ュ鑷村ご閮ㄥ亸閲嶃€?/p>
HTTP 2.0 浣跨敤 HPACK 绠楁硶杩涜鍘嬬缉銆?/p>
浠庝笂闈㈢湅锛屾垜浠彲浠ョ湅鍒扮被浼间簬绱㈠紩琛紝姣忎釜绱㈠紩琛ㄥ搴斾竴涓€硷紝姣斿绱㈠紩涓?瀵瑰簲澶撮儴涓殑method澶撮儴淇℃伅锛岃繖鏍峰瓙鐨勮瘽锛屽湪浼犺緭鐨勬椂鍊欙紝涓嶅湪鏄紶杈撳搴旂殑澶撮儴淇℃伅浜嗭紝鑰屾槸浼犻€掔储寮曪紝瀵逛簬涔嬪墠鍑虹幇杩囩殑澶撮儴淇℃伅锛屽彧闇€瑕佹妸銆岀储寮曘€?/strong>(姣斿1锛?锛?..)浼犵粰瀵规柟鍗冲彲锛屽鏂规嬁鍒扮储寮曟煡琛ㄥ氨琛屼簡銆?/p>
杩欑銆屼紶绱㈠紩銆?/strong>鐨勬柟寮忥紝鍙互璇磋璇锋眰澶村瓧娈靛緱鍒版瀬澶х▼搴︾殑绮剧畝鍜屽鐢ㄣ€?/p>
鍏舵鏄浜庢暣鏁板拰瀛楃涓茶繘琛?span class="mq-113">銆屽搱澶浖缂栫爜銆?/strong>锛屽搱澶浖缂栫爜鐨勫師鐞嗗氨鏄厛灏嗘墍鏈夊嚭鐜扮殑瀛楃寤虹珛涓€寮犵储寮曡〃锛岀劧鍚庤鍑虹幇娆℃暟澶氱殑瀛楃瀵瑰簲鐨勭储寮曞敖鍙兘鐭紝浼犺緭鐨勬椂鍊欎篃鏄紶杈撹繖鏍风殑銆岀储寮曞簭鍒椼€?/strong>锛屽彲浠ヨ揪鍒伴潪甯搁珮鐨勫帇缂╃巼銆?/p>
HTTP 1.x 涓紝濡傛灉鎯冲苟鍙戝涓姹傦紝蹇呴』浣跨敤澶氫釜 TCP 閾炬帴锛屼笖娴忚鍣ㄤ负浜嗘帶鍒惰祫婧愶紝杩樹細瀵瑰崟涓煙鍚嶆湁 6-8涓殑TCP閾炬帴璇锋眰闄愬埗銆?/p>
HTTP2涓細 鍚屽煙鍚嶄笅鎵€鏈夐€氫俊閮藉湪鍗曚釜杩炴帴涓婂畬鎴愩€?/span> 鍗曚釜杩炴帴鍙互鎵胯浇浠绘剰鏁伴噺鐨勫弻鍚戞暟鎹祦銆?br> 鏁版嵁娴佷互娑堟伅鐨勫舰寮忓彂閫侊紝鑰屾秷鎭張鐢变竴涓垨澶氫釜甯х粍鎴愶紝澶氫釜甯т箣闂村彲浠ヤ贡搴忓彂閫侊紝鍥犱负鏍规嵁甯ч閮ㄧ殑娴佹爣璇嗗彲浠ラ噸鏂扮粍瑁咃紝涔熷氨鏄?/span>Stream ID锛屾祦鏍囪瘑绗︼紝鏈変簡瀹冿紝鎺ユ敹鏂瑰氨鑳戒粠涔卞簭鐨勪簩杩涘埗甯т腑閫夋嫨ID鐩稿悓鐨勫抚锛屾寜鐓ч『搴忕粍瑁呮垚璇锋眰/鍝嶅簲鎶ユ枃銆?/span> 娴忚鍣ㄥ彂閫佷竴涓姹傦紝鏈嶅姟鍣ㄤ富鍔ㄥ悜娴忚鍣ㄦ帹閫佷笌杩欎釜璇锋眰鐩稿叧鐨勮祫婧愶紝杩欐牱娴忚鍣ㄥ氨涓嶇敤鍙戣捣鍚庣画璇锋眰銆?/p>
鐩告瘮杈僪ttp/1.1鐨勪紭鍔筐煈?/p>
鎺ㄩ€佽祫婧愬彲浠ョ敱涓嶅悓椤甸潰鍏变韩 鏈嶅姟鍣ㄥ彲浠ユ寜鐓т紭鍏堢骇鎺ㄩ€佽祫婧?/span> 瀹㈡埛绔彲浠ョ紦瀛樻帹閫佺殑璧勬簮 瀹㈡埛绔彲浠ユ嫆鏀舵帹閫佽繃鏉ョ殑璧勬簮 涔嬪墠鏄槑鏂囦紶杈擄紝涓嶆柟渚胯绠楁満瑙f瀽锛屽浜庡洖杞︽崲琛岀鏉ヨ鍒板簳鏄唴瀹硅繕鏄垎闅旂锛岄兘闇€瑕佸唴閮ㄧ姸鎬佹満鍘昏瘑鍒紝杩欐牱瀛愭晥鐜囦綆锛孒TTP/2閲囩敤浜岃繘鍒舵牸寮忥紝鍏ㄩ儴浼犺緭01涓诧紝渚夸簬鏈哄櫒瑙g爜銆?/p>
杩欐牱瀛愪竴涓姤鏂囨牸寮忓氨琚媶鍒嗕负涓€涓釜浜岃繘鍒跺抚锛岀敤銆孒eaders甯с€?/strong>瀛樻斁澶撮儴瀛楁锛?span class="mq-144">銆孌ata甯с€?/strong>瀛樻斁璇锋眰浣撴暟鎹€傝繖鏍峰瓙鐨勮瘽锛屽氨鏄竴鍫嗕贡搴忕殑浜岃繘鍒跺抚锛屽畠浠笉瀛樺湪鍏堝悗鍏崇郴锛屽洜姝や笉闇€瑕佹帓闃熺瓑寰咃紝瑙e喅浜咹TTP闃熷ご闃诲闂銆?/p>
鍦ㄥ鎴风涓庢湇鍔″櫒涔嬮棿锛屽弻鏂归兘鍙互浜掔浉鍙戦€佷簩杩涘埗甯э紝杩欐牱瀛?span class="mq-146">銆屽弻鍚戜紶杈撶殑搴忓垪銆?/strong>锛岀О涓?span class="mq-147">娴?/span>锛屾墍浠TTP/2涓互娴佹潵琛ㄧず涓€涓猅CP杩炴帴涓婅繘琛屽涓暟鎹抚鐨勯€氫俊锛岃繖灏辨槸澶氳矾澶嶇敤姒傚康銆?/p>
閭d贡搴忕殑浜岃繘鍒跺抚锛屾槸濡備綍缁勮鎴愬浜庣殑鎶ユ枃鍛紵 鎵€璋撶殑涔卞簭锛屽€肩殑鏄笉鍚孖D鐨凷tream鏄贡搴忕殑锛屽浜庡悓涓€涓猄tream ID鐨勫抚鏄寜椤哄簭浼犺緭鐨勩€?/span> 鎺ユ敹鏂规敹鍒颁簩杩涘埗甯у悗锛屽皢鐩稿悓鐨凷tream ID缁勮鎴愬畬鏁寸殑璇锋眰鎶ユ枃鍜屽搷搴旀姤鏂囥€?/span> 浜岃繘鍒跺抚涓湁涓€浜涘瓧娈碉紝鎺у埗鐫€浼樺厛绾?/span>鍜?span class="mq-157">娴侀噺鎺у埗绛夊姛鑳斤紝杩欐牱瀛愮殑璇濓紝灏卞彲浠ヨ缃暟鎹抚鐨勪紭鍏堢骇锛岃鏈嶅姟鍣ㄥ鐞嗛噸瑕佽祫婧愶紝浼樺寲鐢ㄦ埛浣撻獙銆?/span> RFC 瑙勫畾 HTTP 鐨勭姸鎬佺爜涓?span class="mq-160">銆屼笁浣嶆暟銆?/strong>锛岀涓€涓暟瀛楀畾涔変簡鍝嶅簲鐨勭被鍒紝琚垎涓轰簲绫? 銆?xx銆?/strong>: 浠h〃璇锋眰宸茶鎺ュ彈锛岄渶瑕佺户缁鐞嗐€?/span> 銆?xx銆?/strong>: 琛ㄧず鎴愬姛鐘舵€併€?/span> 銆?xx銆?/strong>: 閲嶅畾鍚戠姸鎬併€?/span> 銆?xx銆?/strong>: 瀹㈡埛绔敊璇€?/span> 銆?xx銆?/strong>: 鏈嶅姟鍣ㄧ閿欒銆?/span> 鎺ュ彈鐨勮姹傛鍦ㄥ鐞嗭紝淇℃伅绫荤姸鎬佺爜銆?/p>
200 OK 琛ㄧず浠庡鎴风鍙戞潵鐨勮姹傚湪鏈嶅姟鍣ㄧ琚纭姹傘€?/span> 204 No content锛岃〃绀鸿姹傛垚鍔燂紝浣嗘病鏈夎祫婧愬彲杩斿洖銆?/span> 206 Partial Content锛岃鐘舵€佺爜琛ㄧず瀹㈡埛绔繘琛屼簡鑼冨洿璇锋眰锛岃€屾湇鍔″櫒鎴愬姛鎵ц浜嗚繖閮ㄥ垎鐨?GET 璇锋眰 鍝嶅簲鎶ユ枃涓寘鍚敱 銆孋ontent-Range銆?/strong> 鎸囧畾鑼冨洿鐨勫疄浣撳唴瀹广€?/span> 301 moved permanently锛屾案涔呮€ч噸瀹氬悜锛岃〃绀鸿祫婧愬凡琚垎閰嶄簡鏂扮殑 URL锛岃繖鏃跺簲璇ユ寜 Location 棣栭儴瀛楁鎻愮ず鐨?URI 閲嶆柊淇濆瓨銆?/span> 302 found锛屼复鏃舵€ч噸瀹氬悜锛岃〃绀鸿祫婧愪复鏃惰鍒嗛厤浜嗘柊鐨?URL銆?/span> 303 see other锛岃〃绀鸿祫婧愬瓨鍦ㄧ潃鍙︿竴涓?URL锛屽簲浣跨敤 GET 鏂规硶鑾峰彇璧勬簮銆?/span> 304 not modified锛屽綋鍗忓晢缂撳瓨鍛戒腑鏃朵細杩斿洖杩欎釜鐘舵€佺爜銆?/span> 307 temporary redirect锛屼复鏃堕噸瀹氬悜锛屽拰302鍚箟鐩稿悓,涓嶄細鏀瑰彉method 褰?301銆?02銆?03 鍝嶅簲鐘舵€佺爜杩斿洖鏃讹紝鍑犱箮鎵€鏈夌殑娴忚鍣ㄩ兘浼氭妸 POST 鏀规垚 GET锛屽苟鍒犻櫎璇锋眰鎶ユ枃鍐呯殑涓讳綋锛屼箣鍚庤姹備細鑷姩鍐嶆鍙戦€?301銆?02 鏍囧噯鏄姝㈠皢 POST 鏂规硶鏀瑰彉鎴?GET 鏂规硶鐨勶紝浣嗗疄闄呬娇鐢ㄦ椂澶у閮戒細杩欎箞鍋?/p>
400 bad request锛岃姹傛姤鏂囧瓨鍦ㄨ娉曢敊璇€?/span> 401 unauthorized锛岃〃绀哄彂閫佺殑璇锋眰闇€瑕佹湁閫氳繃 HTTP 璁よ瘉鐨勮璇佷俊鎭€?/span> 403 forbidden锛岃〃绀哄璇锋眰璧勬簮鐨勮闂鏈嶅姟鍣ㄦ嫆缁濄€?/span> 404 not found锛岃〃绀哄湪鏈嶅姟鍣ㄤ笂娌℃湁鎵惧埌璇锋眰鐨勮祫婧愩€?/span> 405 Method Not Allowed锛屾湇鍔″櫒绂佹浣跨敤璇ユ柟娉曪紝瀹㈡埛绔彲浠ラ€氳繃options鏂规硶鏉ユ煡鐪嬫湇鍔″櫒鍏佽鐨勮闂柟娉曪紝濡備笅 馃憞 Access-Control-Allow-Methods 鈫扜ET,HEAD,PUT,PATCH,POST,DELETE 500 internal sever error锛岃〃绀烘湇鍔″櫒绔湪鎵ц璇锋眰鏃跺彂鐢熶簡閿欒銆?/span> 502 Bad Gateway锛屾湇鍔″櫒鑷韩鏄甯哥殑锛岃闂殑鏃跺€欏嚭浜嗛棶棰橈紝鍏蜂綋鍟ラ敊璇垜浠笉鐭ラ亾銆?/span> 503 service unavailable锛岃〃鏄庢湇鍔″櫒鏆傛椂澶勪簬瓒呰礋杞芥垨姝e湪鍋滄満缁存姢锛屾棤娉曞鐞嗚姹傘€?/span> 閫掑綊鏌ヨ鎸囩殑鏄煡璇㈣姹傚彂鍑哄悗锛屽煙鍚嶆湇鍔″櫒浠d负鍚戜笅涓€绾у煙鍚嶆湇鍔″櫒鍙戝嚭璇锋眰锛屾渶鍚庡悜鐢ㄦ埛杩斿洖鏌ヨ鐨勬渶缁堢粨鏋溿€備娇鐢ㄩ€掑綊 鏌ヨ锛岀敤鎴峰彧闇€瑕佸彂鍑轰竴娆℃煡璇㈣姹傘€?/span> 杩唬鏌ヨ鎸囩殑鏄煡璇㈣姹傚悗锛屽煙鍚嶆湇鍔″櫒杩斿洖鍗曟鏌ヨ鐨勭粨鏋溿€備笅涓€绾х殑鏌ヨ鐢辩敤鎴疯嚜宸辫姹傘€備娇鐢ㄨ凯浠f煡璇紝鐢ㄦ埛闇€瑕佸彂鍑?澶氭鐨勬煡璇㈣姹傘€?/span> 鎵€浠ヤ竴鑸€岃█锛?span class="mq-241">銆屾湰鍦版湇鍔″櫒鏌ヨ鏄€掑綊鏌ヨ銆?/strong>锛岃€?span class="mq-242">銆屾湰鍦?DNS 鏈嶅姟鍣ㄥ悜鍏朵粬鍩熷悕鏈嶅姟鍣ㄨ姹傜殑杩囩▼鏄凯浠f煡璇㈢殑杩囩▼銆?/strong>銆?/p>
缂撳瓨涔熷緢濂界悊瑙o紝鍦ㄤ竴涓姹備腑锛屽綋鏌愪釜DNS鏈嶅姟鍣ㄦ敹鍒颁竴涓狣NS鍥炵瓟鍚庯紝瀹冭兘澶熷洖绛斾腑鐨勪俊鎭紦瀛樺湪鏈湴瀛樺偍鍣ㄤ腑銆?span class="mq-245">銆岃繑鍥炵殑璧勬簮璁板綍涓殑 TTL 浠h〃浜嗚鏉¤褰曠殑缂撳瓨鐨勬椂闂淬€傘€?/strong> 瀹冩槸濡備綍瀹炵幇璐熻浇鍧囪 鐨勫憿锛熼鍏堟垜浠緱娓呮DNS 鏄彲浠ョ敤浜庡湪鍐椾綑鐨勬湇鍔″櫒涓婂疄鐜拌礋杞藉钩琛°€?/p>
涓句釜渚嬪瓙鏉ヨ馃憞 浠ユ灏嗙敤鎴风殑璇锋眰鍧囪 鐨勫垎閰嶅埌鍚勪釜涓嶅悓鐨勬湇鍔″櫒涓婏紝杩欐牱鏉ュ疄鐜拌礋杞藉潎琛°€?/span> DNS鍩熷悕绯荤粺锛屾槸搴旂敤灞傚崗璁紝杩愯UDP鍗忚涔嬩笂锛屼娇鐢ㄧ鍙?3銆?/span> 鏌ヨ杩囩▼锛屾湰鍦版煡璇㈡槸閫掑綊鏌ヨ锛屼緷娆¢€氳繃娴忚鍣ㄧ紦瀛?鈥?gt;> 鏈湴hosts鏂囦欢 鈥?gt;> 鏈湴DNS瑙f瀽鍣?鈥?gt;>鏈湴DNS鏈嶅姟鍣?鈥?gt;> 鍏朵粬鍩熷悕鏈嶅姟鍣ㄨ姹傘€傛帴涓嬫潵鐨勮繃绋嬪氨鏄凯浠h繃绋嬨€?/span> 閫掑綊鏌ヨ涓€鑸€岃█锛屽彂閫佷竴娆¤姹傚氨澶燂紝杩唬杩囩▼闇€瑕佺敤鎴峰彂閫佸娆¤姹傘€?/span> 銆孌NS 浣跨敤 UDP 鍗忚浣滀负浼犺緭灞傚崗璁殑涓昏鍘熷洜鏄负浜嗛伩鍏嶄娇鐢?TCP 鍗忚鏃堕€犳垚鐨勮繛鎺ユ椂寤躲€傘€?/strong> 鎴戜滑鐭ラ亾HTTP鍗忚閲囩敤鈥滆姹?搴旂瓟鈥濇ā寮忥紝褰撲娇鐢ㄦ櫘閫氭ā寮忥紝鍗抽潪KeepAlive妯″紡鏃讹紝姣忎釜璇锋眰/搴旂瓟瀹㈡埛鍜屾湇鍔″櫒閮借鏂板缓涓€涓繛鎺ワ紝瀹屾垚 涔嬪悗绔嬪嵆鏂紑杩炴帴锛圚TTP鍗忚涓烘棤杩炴帴鐨勫崗璁級锛?/p>
褰撲娇鐢↘eep-Alive妯″紡锛堝張绉版寔涔呰繛鎺ャ€佽繛鎺ラ噸鐢級鏃讹紝Keep-Alive鍔熻兘浣垮鎴风鍒版湇 鍔″櫒绔殑杩炴帴鎸佺画鏈夋晥锛屽綋鍑虹幇瀵规湇鍔″櫒鐨勫悗缁ц姹傛椂锛孠eep-Alive鍔熻兘閬垮厤浜嗗缓绔嬫垨鑰呴噸鏂板缓绔嬭繛鎺ャ€?/p>
keep-alive鎶€鏈殑鍒涘缓鐩殑锛岃兘鍦ㄥ娆TTP涔嬪墠閲嶇敤鍚屼竴涓猅CP杩炴帴锛屼粠鑰屽噺灏戝垱寤?鍏抽棴澶氫釜 TCP 杩炴帴鐨勫紑閿€锛堝寘鎷搷搴旀椂闂淬€丆PU 璧勬簮銆佸噺灏戞嫢鍫电瓑锛夛紝鍙傝€冨涓嬬ず鎰忓浘锛堟潵婧愶細缁村熀鐧剧锛夛細 鍦℉TTP/1.0鍗忚涓紝榛樿鏄叧闂殑锛岄渶瑕佸湪http澶村姞鍏?Connection: Keep-Alive鈥濓紝鎵嶈兘鍚敤Keep-Alive锛?/p>
Connection: keep-alive http 1.1涓粯璁ゅ惎鐢↘eep-Alive锛屽鏋滃姞鍏?Connection: close 鈥滐紝鎵嶅叧闂€?/p>
Connection: close 鐩墠澶ч儴鍒嗘祻瑙堝櫒閮芥槸鐢╤ttp1.1鍗忚锛屼篃灏辨槸璇撮粯璁ら兘浼氬彂璧稫eep-Alive鐨勮繛鎺ヨ姹備簡锛屾墍浠ユ槸鍚﹁兘瀹屾垚涓€涓畬鏁寸殑Keep- Alive杩炴帴灏辩湅鏈嶅姟鍣ㄨ缃儏鍐点€?/p>
杩欎釜璺熶箣鍓嶇殑娴忚鍣ㄧ紦瀛樺師鐞嗕竴鏍凤紝鎴戠洿鎺ユ嬁鎴戜箣鍓嶆⒊鐞嗚繃鐨勫惂銆?/p>
鎴戝湪鎴戜箣鍓嶇殑閭d竴绡囦腑宸茬粡璇︾粏鐨勮杩囦簡锛岀偣杩欓噷浼犻€侀棬鑱婁竴鑱婃祻瑙堝櫒缂撳瓨 鎴戜滑鏉ユ⒊鐞嗕竴涓嬪惂馃憞 寮虹紦瀛樹袱涓浉鍏冲瓧娈碉紝銆孍xpires銆?/strong>锛?span class="mq-291">銆孋ache-Control銆?/strong>銆?/p>
銆屽己缂撳瓨鍒嗕负涓ょ鎯呭喌锛屼竴绉嶆槸鍙戦€丠TTP璇锋眰锛屼竴绉嶄笉闇€瑕佸彂閫併€傘€?/strong> 棣栧厛妫€鏌ュ己缂撳瓨锛岃繖涓樁娈?span class="mq-295">涓嶉渶瑕佸彂閫丠TTP璇锋眰銆?/strong>閫氳繃鏌ユ壘涓嶅悓鐨勫瓧娈垫潵杩涜锛屼笉鍚岀殑HTTP鐗堟湰鎵€浠ヤ笉鍚屻€?/p>
HTTP1.0鐗堟湰锛屼娇鐢ㄧ殑鏄疎xpires锛孒TTP1.1浣跨敤鐨勬槸Cache-Control Expires鍗宠繃鏈熸椂闂达紝鏃堕棿鏄浉瀵逛簬鏈嶅姟鍣ㄧ殑鏃堕棿鑰岃█鐨勶紝瀛樺湪浜庢湇鍔$杩斿洖鐨勫搷搴斿ご涓紝鍦ㄨ繖涓繃鏈熸椂闂翠箣鍓嶅彲浠ョ洿鎺ヤ粠缂撳瓨閲岄潰鑾峰彇鏁版嵁锛屾棤闇€鍐嶆璇锋眰銆傛瘮濡備笅闈㈣繖鏍? Expires:Mon, 29 Jun 2020 11:10:23 GMT 琛ㄧず璇ヨ祫婧愬湪2020骞?span class="mq-315">7鏈?9鏃?1:10:23 杩欎釜鏂瑰紡鏈変竴涓棶棰橈細銆屾湇鍔″櫒鐨勬椂闂村拰娴忚鍣ㄧ殑鏃堕棿鍙兘骞朵笉涓€鑷淬€?/strong>锛屾墍浠TTP1.1鎻愬嚭鏂扮殑瀛楁浠f浛瀹冦€?/p>
HTTP1.1鐗堟湰涓紝浣跨敤鐨勫氨鏄瀛楁锛岃繖涓瓧娈甸噰鐢ㄧ殑鏃堕棿鏄繃鏈熸椂闀匡紝瀵瑰簲鐨勬槸max-age銆?/p>
Cache-Control:max-age=6000 涓婇潰浠h〃璇ヨ祫婧愯繑鍥炲悗6000绉掞紝鍙互鐩存帴浣跨敤缂撳瓨銆?/p>
褰撶劧浜嗭紝瀹冭繕鏈夊叾浠栧緢澶氬叧閿殑鎸囦护锛屾⒊鐞嗕簡鍑犱釜閲嶈鐨勷煈?/p>
娉ㄦ剰鐐癸細 褰揈xpires鍜孋ache-Control鍚屾椂瀛樺湪鏃讹紝浼樺厛鑰冭檻Cache-Control銆?/span> 褰撶劧浜嗭紝褰撶紦瀛樿祫婧愬け鏁堜簡锛屼篃灏辨槸娌℃湁鍛戒腑寮虹紦瀛橈紝鎺ヤ笅鏉ュ氨杩涘叆鍗忓晢缂撳瓨馃憞 寮虹紦瀛樺け鏁堝悗锛屾祻瑙堝櫒鍦ㄨ姹傚ご涓惡甯﹀搷搴旂殑缂撳瓨Tag鏉ュ悜鏈嶅姟鍣ㄥ彂閫佽姹傦紝鏈嶅姟鍣ㄦ牴鎹搴旂殑tag锛屾潵鍐冲畾鏄惁浣跨敤缂撳瓨銆?/p>
缂撳瓨鍒嗕负涓ょ锛?span class="mq-340">銆孡ast-Modified銆?/strong> 鍜?銆孍Tag銆?/strong>銆備袱鑰呭悇鏈変紭鍔匡紝骞朵笉瀛樺湪璋佸璋佹湁缁濆鐨勪紭鍔?/span>锛屼笌涓婇潰鎵€璁茬殑寮虹紦瀛樹袱涓猅ag鎵€涓嶅悓銆?/p>
杩欎釜瀛楁琛ㄧず鐨勬槸銆屾渶鍚庝慨鏀规椂闂淬€?/strong>銆傚湪娴忚鍣ㄧ涓€娆$粰鏈嶅姟鍣ㄥ彂閫佽姹傚悗锛屾湇鍔″櫒浼氬湪鍝嶅簲澶翠腑鍔犱笂杩欎釜瀛楁銆?/p>
娴忚鍣ㄦ帴鏀跺埌鍚庯紝銆屽鏋滃啀娆¤姹傘€?/strong>锛屼細鍦ㄨ姹傚ご涓惡甯?span class="mq-348">If-Modified-Since瀛楁锛岃繖涓瓧娈电殑鍊间篃灏辨槸鏈嶅姟鍣ㄤ紶鏉ョ殑鏈€鍚庝慨鏀规椂闂淬€?/p>
鏈嶅姟鍣ㄦ嬁鍒拌姹傚ご涓殑If-Modified-Since鐨勫瓧娈靛悗锛屽叾瀹炰細鍜岃繖涓湇鍔″櫒涓?span class="mq-351">璇ヨ祫婧愮殑鏈€鍚庝慨鏀规椂闂?/span>瀵规瘮: 濡傛灉璇锋眰澶翠腑鐨勮繖涓€煎皬浜庢渶鍚庝慨鏀规椂闂达紝璇存槑鏄椂鍊欐洿鏂颁簡銆傝繑鍥炴柊鐨勮祫婧愶紝璺熷父瑙勭殑HTTP璇锋眰鍝嶅簲鐨勬祦绋嬩竴鏍枫€?/span> 鍚﹀垯杩斿洖304锛屽憡璇夋祻瑙堝櫒鐩存帴浣跨敤缂撳瓨銆?/span> ETag鏄湇鍔″櫒鏍规嵁褰撳墠鏂囦欢鐨勫唴瀹癸紝瀵规枃浠剁敓鎴愬敮涓€鐨勬爣璇嗭紝姣斿MD5绠楁硶锛屽彧瑕侀噷闈㈢殑鍐呭鏈夋敼鍔紝杩欎釜鍊煎氨浼氫慨鏀癸紝鏈嶅姟鍣ㄩ€氳繃鎶婂搷搴斿ご鎶婅瀛楁缁欐祻瑙堝櫒銆?/p>
娴忚鍣ㄦ帴鍙楀埌ETag鍊硷紝浼氬湪涓嬫璇锋眰鐨勬椂鍊欙紝灏嗚繖涓€间綔涓?span class="mq-360">銆孖f-None-Match銆?/strong>杩欎釜瀛楁鐨勫唴瀹癸紝鍙戠粰鏈嶅姟鍣ㄣ€?/p>
鏈嶅姟鍣ㄦ帴鏀跺埌銆孖f-None-Match銆?/strong>鍚庯紝浼氳窡鏈嶅姟鍣ㄤ笂璇ヨ祫婧愮殑銆孍Tag銆?/strong>杩涜姣斿馃憞 濡傛灉涓よ€呬竴鏍风殑璇濓紝鐩存帴杩斿洖304锛屽憡璇夋祻瑙堝櫒鐩存帴浣跨敤缂撳瓨 濡傛灉涓嶄竴鏍风殑璇濓紝璇存槑鍐呭鏇存柊浜嗭紝杩斿洖鏂扮殑璧勬簮锛岃窡甯歌鐨凥TTP璇锋眰鍝嶅簲鐨勬祦绋嬩竴鏍?/span> 鎬ц兘涓婏紝Last-Modified浼樹簬ETag锛?span class="mq-375">Last-Modified璁板綍鐨勬槸鏃堕棿鐐癸紝鑰?span class="mq-376">Etag 绮惧害涓婏紝ETag浼樹簬Last-Modified銆?span class="mq-381">ETag鎸夌収鍐呭缁欒祫婧愬甫涓婃爣璇嗭紝鑳藉噯纭劅鐭ヨ祫婧愬彉鍖栵紝Last-Modified鍦ㄦ煇浜涘満鏅苟涓嶈兘鍑嗙‘鎰熺煡鍙樺寲锛屾瘮濡傪煈?/span> 缂栬緫浜嗚祫婧愭枃浠讹紝浣嗘槸鏂囦欢鍐呭骞舵病鏈夋洿鏀癸紝杩欐牱涔熶細閫犳垚缂撳瓨澶辨晥銆?/span> Last-Modified 鑳藉鎰熺煡鐨勫崟浣嶆椂闂存槸绉掞紝濡傛灉鏂囦欢鍦?1 绉掑唴鏀瑰彉浜嗗娆★紝閭d箞杩欐椂鍊欑殑 Last-Modified 骞舵病鏈変綋鐜板嚭淇敼浜嗐€?/span> 鏈€鍚庯紝銆屽鏋滀袱绉嶆柟寮忛兘鏀寔鐨勮瘽锛屾湇鍔″櫒浼氫紭鍏堣€冭檻ETag銆?/strong>銆?/p>
鎺ヤ笅鏉ユ垜浠€冭檻浣跨敤缂撳瓨鐨勮瘽锛岀紦瀛樼殑浣嶇疆鍦ㄥ摢閲屽憿锛?/p>
娴忚鍣ㄧ紦瀛樼殑浣嶇疆鐨勮瘽锛屽彲浠ュ垎涓哄洓绉?浼樺厛绾т粠楂樺埌浣庢帓鍒楀垎鍒煈?/p>
Service Worker Memory Cache Disk Cache Push Cache 杩欎釜搴旂敤鍦烘櫙姣斿PWA锛屽畠鍊熼壌浜哤eb Worker鎬濊矾锛岀敱浜庡畠鑴辩浜嗘祻瑙堝櫒鐨勭獥浣擄紝鍥犳鏃犳硶鐩存帴璁块棶DOM銆傚畠鑳藉畬鎴愮殑鍔熻兘姣斿锛?span class="mq-405">绂荤嚎缂撳瓨 鎸囩殑鏄唴瀛樼紦瀛橈紝浠庢晥鐜囦笂璁插畠鏄渶蹇殑锛屼粠瀛樻椿鏃堕棿鏉ヨ鍙堟槸鏈€鐭殑锛屽綋娓叉煋杩涚▼缁撴潫鍚庯紝鍐呭瓨缂撳瓨涔熷氨涓嶅瓨鍦ㄤ簡銆?/p>
瀛樺偍鍦ㄧ鐩樹腑鐨勭紦瀛橈紝浠庡瓨鍙栨晥鐜囦笂璁叉槸姣斿唴瀛樼紦瀛樻參鐨勶紝浼樺娍鍦ㄤ簬瀛樺偍瀹归噺鍜屽瓨鍌ㄦ椂闀裤€?/p>
涓よ€呭姣旓紝涓昏鐨勭瓥鐣ヰ煈?/p>
鍐呭浣跨敤鐜囬珮鐨勮瘽锛屾枃浠朵紭鍏堣繘鍏ョ鐩?/p>
姣旇緝澶х殑JS锛孋SS鏂囦欢浼氱洿鎺ユ斁鍏ョ鐩橈紝鍙嶄箣鏀惧叆鍐呭瓨銆?/p>
鎺ㄩ€佺紦瀛橈紝杩欑畻鏄祻瑙堝櫒涓渶鍚庝竴閬撻槻绾垮惂锛屽畠鏄?span class="mq-420">HTTP/2 棣栧厛妫€鏌?span class="mq-426">Cache-Control锛?灏濋矞锛岀湅寮虹紦瀛樻槸鍚﹀彲鐢?span class="mq-427">濡傛灉鍙敤鐨勮瘽锛岀洿鎺ヤ娇鐢?/span> 鍚﹀垯杩涘叆鍗忓晢缂撳瓨锛屽彂閫丠TTP璇锋眰锛屾湇鍔″櫒閫氳繃璇锋眰澶翠腑鐨?span class="mq-431">If-Modified-Since鎴栬€?span class="mq-432">If-None-Match 璧勬簮鏇存柊锛岃繑鍥炶祫婧愬拰200鐘舵€佺爜銆?/span> 鍚﹀垯锛岃繑鍥?04锛岀洿鎺ュ憡璇夋祻瑙堝櫒鐩存帴浠庣紦瀛樹腑鍘昏祫婧愩€?/span> HTTP1.0瀹氫箟浜嗕笁绉嶈姹傛柟娉曪細GET, POST 鍜?HEAD鏂规硶 HTTP1.1鏂板浜嗕簲绉嶈姹傛柟娉曪細OPTIONS, PUT, DELETE, TRACE 鍜?CONNECT http/1.1瑙勫畾浜嗕互涓嬭姹傛柟娉?娉ㄦ剰锛岄兘鏄ぇ鍐?: GET锛?nbsp; 璇锋眰鑾峰彇Request-URI鎵€鏍囪瘑鐨勮祫婧?/span> POST锛?nbsp; 鍦≧equest-URI鎵€鏍囪瘑鐨勮祫婧愬悗闄勫姞鏂扮殑鏁版嵁 HEAD锛?nbsp; 璇锋眰鑾峰彇鐢盧equest-URI鎵€鏍囪瘑鐨勮祫婧愮殑鍝嶅簲娑堟伅鎶ュご PUT锛?nbsp; 璇锋眰鏈嶅姟鍣ㄥ瓨鍌ㄤ竴涓祫婧愶紝骞剁敤Request-URI浣滀负鍏舵爣璇嗭紙淇敼鏁版嵁锛?/span> DELETE锛?nbsp; 璇锋眰鏈嶅姟鍣ㄥ垹闄ゅ搴旀墍鏍囪瘑鐨勮祫婧?/span> TRACE锛?nbsp; 璇锋眰鏈嶅姟鍣ㄥ洖閫佹敹鍒扮殑璇锋眰淇℃伅锛屼富瑕佺敤浜庢祴璇曟垨璇婃柇 CONNECT锛?nbsp; 寤虹珛杩炴帴闅ч亾锛岀敤浜庝唬鐞嗘湇鍔″櫒 OPTIONS锛?nbsp; 鍒楀嚭鍙璧勬簮瀹炶鐨勮姹傛柟娉曪紝鐢ㄦ潵璺ㄥ煙璇锋眰 鏈川涓婏紝鍙槸璇箟涓婄殑鍖哄埆锛孏ET 鐢ㄤ簬鑾峰彇璧勬簮锛孭OST 鐢ㄤ簬鎻愪氦璧勬簮銆?/p>
鎯宠閫艰鍙傝€?https://zhuanlan.zhihu.com/p/22536382 鍏蜂綋宸埆馃憞 浠庣紦瀛樿搴︾湅锛孏ET 璇锋眰鍚庢祻瑙堝櫒浼氫富鍔ㄧ紦瀛橈紝POST 榛樿鎯呭喌涓嬩笉鑳姐€?/span> 浠庡弬鏁拌搴︽潵鐪嬶紝GET璇锋眰涓€鑸斁鍦║RL涓紝鍥犳涓嶅畨鍏紝POST璇锋眰鏀惧湪璇锋眰浣撲腑锛岀浉瀵硅€岃█杈冧负瀹夊叏锛屼絾鏄湪鎶撳寘鐨勬儏鍐典笅閮芥槸涓€鏍风殑銆?/span> 浠庣紪鐮佽搴︾湅锛孏ET璇锋眰鍙兘缁忚URL缂栫爜锛屽彧鑳芥帴鍙桝SCII鐮侊紝鑰孭OST鏀寔鏇村鐨勭紪鐮佺被鍨嬩笖涓嶅鏁版嵁绫诲瀷闄愬€笺€?/span> GET璇锋眰骞傜瓑锛孭OST璇锋眰涓嶅箓绛夛紝骞傜瓑鎸囧彂閫?M 鍜?N 娆¤姹傦紙涓よ€呬笉鐩稿悓涓旈兘澶т簬1锛夛紝鏈嶅姟鍣ㄤ笂璧勬簮鐨勭姸鎬佷竴鑷淬€?/span> GET璇锋眰浼氫竴娆℃€у彂閫佽姹傛姤鏂囷紝POST璇锋眰閫氬父鍒嗕负涓や釜TCP鏁版嵁鍖咃紝棣栧厛鍙?header 閮ㄥ垎锛屽鏋滄湇鍔″櫒鍝嶅簲 100(continue)锛?鐒跺悗鍙?body 閮ㄥ垎銆?/span> 浠庡簲鐢ㄥ満鏅搴︽潵鐪嬶紝Get 澶氱敤浜庢棤鍓綔鐢紝骞傜瓑鐨勫満鏅紝渚嬪鎼滅储鍏抽敭瀛椼€侾ost 澶氱敤浜庡壇浣滅敤锛屼笉骞傜瓑鐨勫満鏅紝渚嬪娉ㄥ唽銆?/p>
OPTIONS 璇锋眰涓?HEAD 绫讳技锛屼竴鑸篃鏄敤浜庡鎴风鏌ョ湅鏈嶅姟鍣ㄧ殑鎬ц兘銆?/span> 杩欎釜鏂规硶浼氳姹傛湇鍔″櫒杩斿洖璇ヨ祫婧愭墍鏀寔鐨勬墍鏈?HTTP 璇锋眰鏂规硶锛岃鏂规硶浼氱敤'*'鏉ヤ唬鏇胯祫婧愬悕绉帮紝鍚戞湇鍔″櫒鍙戦€?OPTIONS 璇锋眰锛屽彲浠ユ祴璇曟湇鍔″櫒鍔熻兘鏄惁姝e父銆?/span> JS 鐨?XMLHttpRequest瀵硅薄杩涜 CORS 璺ㄥ煙璧勬簮鍏变韩鏃讹紝瀵逛簬澶嶆潅璇锋眰锛屽氨鏄娇鐢?OPTIONS 鏂规硶鍙戦€佸梾鎺㈣姹傦紝浠ュ垽鏂槸鍚︽湁瀵规寚瀹氳祫婧愮殑璁块棶鏉冮檺銆?/span> 閫氱敤鐨勬牸寮忥細scheme://host[:port]/path/鈥??query#anchor 涓句釜渚嬪瓙馃憞 https://www.baidu.com/s?tn=baidu&bar=&wd=TianTian 杩欎釜URL涓紝https灏辨槸鍗忚锛寃ww.baidu.com灏辨槸鍩熷悕锛岄粯璁ょ鍙f槸443锛?s灏辨槸璇锋眰鐨刾ath锛?span class="mq-529">tn=baidu&bar=&wd=TianTian URL 鍙兘浣跨敤 ASCII 瀛楃闆嗘潵閫氳繃鍥犵壒缃戣繘琛屽彂閫併€?/span> 鐢变簬 URL 甯稿父浼氬寘鍚?ASCII 闆嗗悎涔嬪鐨勫瓧绗︼紝URL 蹇呴』杞崲涓烘湁鏁堢殑 ASCII 鏍煎紡銆?/span> URL 缂栫爜浣跨敤 "%" 鍏跺悗璺熼殢涓や綅鐨勫崄鍏繘鍒舵暟鏉ユ浛鎹㈤潪 ASCII 瀛楃銆?/span> URL 涓嶈兘鍖呭惈绌烘牸銆俇RL 缂栫爜閫氬父浣跨敤 + 鏉ユ浛鎹㈢┖鏍笺€?/span> 涓句釜渚嬪瓙馃憞 澶╁ぉ杞崲涓烘湁鏁堢殑ASCII鏍煎紡灏辨槸%CC%EC%CC%EC 瀵逛簬姣忎竴涓狧TTP璇锋眰鑰岃█锛岃繖浜涗换鍔℃槸浼氳鏀惧叆涓€涓换鍔¢槦鍒椾腑涓茶鎵ц鐨勶紝涓€鏃﹂槦棣栦换鍔¤姹傚お鎱㈡椂锛屽氨浼氶樆濉炲悗闈㈢殑璇锋眰澶勭悊锛岃繖灏辨槸HTTP闃熷ご闃诲闂銆?/p>
鏈変粈涔堣В鍐冲姙娉曞悧馃憞 鎴戜滑鐭ラ亾瀵逛簬涓€涓煙鍚嶈€岃█锛屾槸鍏佽鍒嗛厤澶氫釜闀胯繛鎺ョ殑锛岄偅涔堝彲浠ョ悊瑙f垚澧炲姞浜嗕换鍔¢槦鍒楋紝涔熷氨鏄涓嶄細瀵艰嚧涓€涓换鍔¢樆濉炰簡璇ヤ换鍔¢槦鍒楃殑鍏朵粬浠诲姟锛屽湪RFC瑙勮寖涓瀹氬鎴风鏈€澶氬苟鍙?涓繛鎺ワ紝涓嶈繃瀹為檯鎯呭喌灏辨槸瑕佹瘮杩欎釜杩樿澶氾紝涓句釜渚嬪瓙锛孋hrome涓槸6涓€?/p>
椤惧悕鎬濅箟锛屾垜浠彲浠ュ湪涓€涓煙鍚嶄笅鍒嗗嚭澶氫釜浜岀骇鍩熷悕鍑烘潵锛岃€屽畠浠渶缁堟寚鍚戠殑杩樻槸鍚屼竴涓湇鍔″櫒锛岃繖鏍峰瓙鐨勮瘽灏卞彲浠ュ苟鍙戝鐞嗙殑浠诲姟闃熷垪鏇村锛屼篃鏇村ソ鐨勮В鍐充簡闃熷ご闃诲鐨勯棶棰樸€?/p>
涓句釜渚嬪瓙锛屾瘮濡?span class="mq-557">TianTian.com 澶ф閬囧埌鐨勬儏鍐靛氨鍒嗕负銆屽畾闀挎暟鎹€?/strong> 涓?銆屼笉瀹氶暱鏁版嵁銆?/strong>鐨勫鐞嗗惂銆?/p>
瀵逛簬瀹氶暱鐨勬暟鎹寘鑰岃█锛屽彂閫佺鍦ㄥ彂閫佹暟鎹殑杩囩▼涓紝闇€瑕佽缃?span class="mq-567">Content-Length 褰撶劧浜嗗鏋滈噰鐢ㄤ簡Gzip鍘嬬缉鐨勮瘽锛孋ontent-Length璁剧疆鐨勫氨鏄帇缂╁悗鐨勪紶杈撻暱搴︺€?/p>
鎴戜滑杩橀渶瑕佺煡閬撶殑鏄煈?/p>
Content-Length濡傛灉瀛樺湪骞朵笖鏈夋晥鐨勮瘽锛屽垯蹇呴』鍜屾秷鎭唴瀹圭殑浼犺緭闀垮害瀹屽叏涓€鑷达紝涔熷氨鏄锛屽鏋滆繃鐭氨浼氭埅鏂紝杩囬暱鐨勮瘽锛屽氨浼氬鑷磋秴鏃躲€?/span> 濡傛灉閲囩敤鐭摼鎺ョ殑璇濓紝鐩存帴鍙互閫氳繃鏈嶅姟鍣ㄥ叧闂繛鎺ユ潵纭畾娑堟伅鐨勪紶杈撻暱搴︺€?/span> 閭d箞鍦℉TTP/1.0涔嬪墠鐨勭増鏈腑锛孋ontent-Length瀛楁鍙湁鍙棤,鍥犱负涓€鏃︽湇鍔″櫒鍏抽棴杩炴帴锛屾垜浠氨鍙互鑾峰彇鍒颁紶杈撴暟鎹殑闀垮害浜嗐€?br> 鍦℉TTP/1.1鐗堟湰涓紝濡傛灉鏄疜eep-alive鐨勮瘽锛宑hunked浼樺厛绾ч珮浜?/span>Content-Length,鑻ユ槸闈濳eep-alive锛岃窡鍓嶉潰鎯呭喌涓€鏍凤紝Content-Length鍙湁鍙棤銆?/span> 閭f€庝箞鏉ヨ缃?span class="mq-585">Content-Length 涓句釜渚嬪瓙鏉ョ湅鐪嬸煈?/p>
const server = require('http').createServer(); server.on('request', (req, res) => { if(req.url === '/index') { // 璁剧疆鏁版嵁绫诲瀷 res.setHeader('Content-Type', 'text/plain'); res.setHeader('Content-Length', 10); res.write("浣犲ソ锛屼娇鐢ㄧ殑鏄疌ontent-Length璁剧疆浼犺緭鏁版嵁褰㈠紡"); } }) server.listen(3000, () => { console.log("鎴愬姛鍚姩--TinaTian"); }) 鐜板湪閲囩敤鏈€澶氱殑灏辨槸HTTP/1.1鐗堟湰锛屾潵瀹屾垚浼犺緭鏁版嵁锛屽湪淇濆瓨Keep-alive鐘舵€佷笅锛屽綋鏁版嵁鏄笉瀹氶暱鐨勬椂鍊欙紝鎴戜滑闇€瑕佽缃柊鐨勫ご閮ㄥ瓧娈叼煈?/p>
Transfer-Encoding: chunked 閫氳繃chunked鏈哄埗锛屽彲浠ュ畬鎴愬涓嶅畾闀挎暟鎹殑澶勭悊锛屽綋鐒朵簡锛屼綘闇€瑕佺煡閬撶殑鏄?/p>
濡傛灉澶撮儴淇℃伅涓湁Transfer-Encoding,浼樺厛閲囩敤Transfer-Encoding閲岄潰鐨勬柟娉曟潵鎵惧埌瀵瑰簲鐨勯暱搴︺€?/span> 濡傛灉璁剧疆浜員ransfer-Encoding锛岄偅涔圕ontent-Length灏嗚蹇借銆?/span> 浣跨敤闀胯繛鎺ョ殑璇濓紝浼氭寔缁殑鎺ㄩ€佸姩鎬佸唴瀹广€?/span> 閭f垜浠潵妯℃嫙涓€涓嬪惂馃憞 const server = require('http').createServer(); server.on('request', (req, res) => { if(req.url === '/index') { // 璁剧疆鏁版嵁绫诲瀷 res.setHeader('Content-Type', 'text/html; charset=utf8'); res.setHeader('Content-Length', 10); res.setHeader('Transfer-Encoding', 'chunked'); res.write("浣犲ソ锛屼娇鐢ㄧ殑鏄疶ransfer-Encoding璁剧疆浼犺緭鏁版嵁褰㈠紡"); setTimeout(() => { res.write("绗竴娆′紶杈撴暟鎹粰鎮?lt;br/>"); }, 1000); res.write("楠氱瓑涓€涓?); setTimeout(() => { res.write("绗竴娆′紶杈撴暟鎹粰鎮?); res.end() }, 3000); } }) server.listen(3000, () => { console.log("鎴愬姛鍚姩--TinaTian"); }) 涓婇潰浣跨敤鐨勬槸nodejs涓環ttp妯″潡锛屾湁鍏磋叮鐨勫皬浼欎即鍙互鍘昏瘯涓€璇曪紝浠ヤ笂灏辨槸HTTP瀵?span class="mq-813">銆屽畾闀挎暟鎹€?/strong>鍜?span class="mq-814">銆屼笉瀹氶暱鏁版嵁銆?/strong>浼犺緭杩囩▼涓殑澶勭悊鎵嬫銆?/p>
HTTPS 瑕佹瘮 HTTPS 澶氫簡 secure 瀹夊叏鎬ц繖涓蹇碉紝瀹為檯涓婏紝 HTTPS 骞朵笉鏄竴涓柊鐨勫簲鐢ㄥ眰鍗忚锛屽畠鍏跺疄灏辨槸 HTTP + TLS/SSL 鍗忚缁勫悎鑰屾垚锛岃€屽畨鍏ㄦ€х殑淇濊瘉姝f槸 SSL/TLS 鎵€鍋氱殑宸ヤ綔銆?/p>
銆孲SL銆?/strong> 瀹夊叏濂楁帴灞傦紙Secure Sockets Layer锛?/p>
銆孴LS銆?/strong> 锛堜紶杈撳眰瀹夊叏锛孴ransport Layer Security锛?/p>
鐜板湪涓绘祦鐨勭増鏈槸 TLS/1.2, 涔嬪墠鐨?TLS1.0銆乀LS1.1 閮借璁や负鏄笉瀹夊叏鐨勶紝鍦ㄤ笉涔呯殑灏嗘潵浼氳瀹屽叏娣樻卑銆?/p>
銆孒TTPS 灏辨槸韬姭浜嗕竴灞?SSL 鐨?HTTP銆?/strong>銆?/p>
閭d箞鍖哄埆鏈夊摢浜涘憿馃憞 HTTP 鏄槑鏂囦紶杈撳崗璁紝HTTPS 鍗忚鏄敱 SSL+HTTP 鍗忚鏋勫缓鐨勫彲杩涜鍔犲瘑浼犺緭銆佽韩浠借璇佺殑缃戠粶鍗忚锛屾瘮 HTTP 鍗忚瀹夊叏銆?/span> HTTPS姣擧TTP鏇村姞瀹夊叏锛屽鎼滅储寮曟搸鏇村弸濂斤紝鍒╀簬SEO,璋锋瓕銆佺櫨搴︿紭鍏堢储寮旽TTPS缃戦〉銆?br> HTTPS鏍囧噯绔彛443锛孒TTP鏍囧噯绔彛80銆?br> HTTPS闇€瑕佺敤鍒癝SL璇佷功锛岃€孒TTP涓嶇敤銆?/span> 鎴戣寰楄浣忎互涓嬩袱鐐笻TTPS涓昏浣滅敤灏辫馃憞 瀵规暟鎹繘琛屽姞瀵嗭紝骞跺缓绔嬩竴涓俊鎭畨鍏ㄩ€氶亾锛屾潵淇濊瘉浼犺緭杩囩▼涓殑鏁版嵁瀹夊叏; 瀵圭綉绔欐湇鍔″櫒杩涜鐪熷疄韬唤璁よ瘉銆?/span> 涓婁竴鑺傛潵鐪嬶紝鎴戜滑鍙互鎶奌TTPS鐞嗚В鎴?span class="mq-846">銆孒TTPS = HTTP + SSL/TLS銆?/strong> TLS/SSL 鐨勫姛鑳藉疄鐜颁富瑕佷緷璧栦簬涓夌被鍩烘湰绠楁硶锛?span class="mq-849">鏁e垪鍑芥暟HTTP 鐗圭偣
HTTP 缂虹偣
HTTP/1.0 HTTP1.1 HTTP2.0鐗堟湰涔嬮棿鐨勫樊寮?/h2>
HTTP 0.9
HTTP 1.0
HTTP 1.1
http1.x鐗堟湰闂
HTTP 2.0
璋堜竴璋堜綘瀵笻TTP/2鐞嗚В
澶撮儴鍘嬬缉
澶氳矾澶嶇敤
鏈嶅姟鍣ㄦ帹閫?/h3>
浜岃繘鍒跺垎甯?/h3>
浠嬬粛涓€涓婬TTP 甯歌鐘舵€佺爜
1xx 淇℃伅绫?/h3>
2xx 鎴愬姛
3xx 閲嶅畾鍚?/h3>
4XX 瀹㈡埛绔敊璇?/h3>
5XX 鏈嶅姟鍣ㄩ敊璇?/h3>
DNS濡備綍宸ヤ綔鐨?/h2>
閫掑綊鏌ヨ鍜岃凯浠f煡璇?/h3>
DNS缂撳瓨
DNS瀹炵幇璐熻浇骞宠
鎬荤粨
DNS 涓轰粈涔堜娇鐢?UDP 鍗忚浣滀负浼犺緭灞傚崗璁紵
浠嬬粛涓€涓婥onnection:keep-alive
浠€涔堟槸keep-alive
涓轰粈涔堣浣跨敤keep-alive
瀹㈡埛绔浣曞紑鍚?/h3>
浠嬬粛HTTP 缂撳瓨绛栫暐
寮虹紦瀛?/h3>
Expires
Cache-Control
鍗忓晢缂撳瓨
Last-Modified
ETag
涓よ€呭姣?/h4>
闇€瑕佹牴鎹枃浠剁殑MD5绠楁硶鐢熸垚瀵瑰簲鐨刪ash鍊笺€?/span>
缂撳瓨浣嶇疆
Service Worker
Memory Cache
Disk Cache
Disk Cache VS Memory Cache
Push Cache
鎬荤粨
璇翠竴璇碒TTP 鐨勮姹傛柟娉曪紵
璋堜竴璋圙ET 鍜?POST 鐨勫尯鍒?/h2>
options 鏂规硶鏈変粈涔堢敤锛?/h2>
璋堜竴璋堜綘瀵筓RL鐞嗚В
缁勬垚
鍚嶇О
鍔熻兘
scheme
璁块棶鏈嶅姟鍣ㄤ互鑾峰彇璧勬簮鏃惰浣跨敤鍝鍗忚锛屾瘮濡傦細http锛宧ttps 鍜?FTP 绛?/td>
host
HTTP 鏈嶅姟鍣ㄧ殑 IP 鍦板潃鎴栬€呭煙鍚?/td>
port
HTTP 鏈嶅姟鍣ㄧ殑榛樿绔彛鏄?80锛孒TTPS榛樿绔彛鏄?43锛岃繖绉嶆儏鍐典笅绔彛鍙峰彲浠ョ渷鐣ワ紝濡傛灉浣跨敤浜嗗埆鐨勭鍙o紝蹇呴』鎸囨槑銆備笉鍚岀殑绔彛锛屼綘鍙互璁や负鏄笉鍚岀殑搴旂敤绋嬪簭銆?/td>
path
璁块棶璧勬簮鐨勮矾寰?/td>
query-string
鍙戠粰 http 鏈嶅姟鍣ㄧ殑鏁版嵁
anchor
閿氱偣
URL 缂栫爜
璋堜竴璋堥槦澶撮樆濉為棶棰?/h2>
浠€涔堟槸闃熷ご闃诲锛?/h3>
骞跺彂杩炴帴
鍩熷悕鍒嗙墖
璋堜竴璋圚TTP鏁版嵁浼犺緭
瀹氶暱鏁版嵁
涓嶅畾闀挎暟鎹?/h3>
浠嬬粛涓€涓婬TTPS鍜孒TTP鍖哄埆
浠嬬粛涓€涓狧TTPS宸ヤ綔鍘熺悊
銆?span class="mq-850">瀵圭О鍔犲瘑
瀵圭О鍔犲瘑
鍔犲瘑鍜岃В瀵嗙敤鍚屼竴涓閽ョ殑鍔犲瘑鏂瑰紡鍙仛瀵圭О鍔犲瘑銆侰lient瀹㈡埛绔拰Server绔叡鐢ㄤ竴濂楀瘑閽ワ紝杩欐牱瀛愮殑鍔犲瘑杩囩▼浼间箮寰堣浜虹悊瑙o紝浣嗘槸闅忎箣浼氫骇鐢熶竴浜涢棶棰樸€?/p>
銆岄棶棰樹竴:銆?/strong> WWW涓囩淮缃戞湁璁歌澶氬鐨勫鎴风锛屼笉鍙兘閮界敤绉橀挜A杩涜淇℃伅鍔犲瘑锛岃繖鏍峰瓙寰堜笉鍚堢悊锛屾墍浠ヨВ鍐冲姙娉曞氨鏄娇鐢ㄤ竴涓鎴风浣跨敤涓€涓瘑閽ヨ繘琛屽姞瀵嗐€?/p>
銆岄棶棰樹簩:銆屾棦鐒朵笉鍚岀殑瀹㈡埛绔娇鐢ㄤ笉鍚岀殑瀵嗛挜锛岄偅涔堛€?span class="mq-858">瀵圭О鍔犲瘑鐨勫瘑閽ュ浣曚紶杈擄紵銆?/strong> 閭d箞瑙e喅鐨勫姙娉曞彧鑳芥槸銆屼竴绔敓鎴愪竴涓閽ワ紝鐒跺悗閫氳繃HTTP浼犺緭缁欏彟涓€绔€?/strong>锛岄偅涔堣繖鏍峰瓙鍙堜細浜х敓鏂扮殑闂銆?/p>
銆岄棶棰樹笁:銆?/strong> 杩欎釜浼犺緭瀵嗛挜鐨勮繃绋嬶紝鍙堝浣曚繚璇佸姞瀵嗭紵銆屽鏋滆涓棿浜烘嫤鎴紝瀵嗛挜涔熶細琚幏鍙?銆?/strong> 閭d箞浣犱細璇村瀵嗛挜鍐嶈繘琛屽姞瀵嗭紝閭e張鎬庝箞淇濆瓨瀵瑰瘑閽ュ姞瀵嗙殑杩囩▼锛屾槸鍔犲瘑鐨勮繃绋嬶紵 鍒拌繖閲岋紝鎴戜滑浼间箮鎯虫槑鐧戒簡锛屼娇鐢ㄥ绉板姞瀵嗙殑鏂瑰紡锛岃涓嶉€氾紝鎵€浠ユ垜浠渶瑕侀噰鐢ㄩ潪瀵圭О鍔犲瘑馃憞 閫氳繃涓婇潰鐨勫垎鏋愶紝瀵圭О鍔犲瘑鐨勬柟寮忚涓嶉€氾紝閭d箞鎴戜滑鏉ユ⒊鐞嗕竴涓嬮潪瀵圭О鍔犲瘑銆傞噰鐢ㄧ殑绠楁硶鏄疪SA锛屾墍浠ュ湪涓€浜涙枃绔犱腑涔熶細鐪嬭銆屼紶缁烺SA鎻℃墜銆?/strong>锛屽熀浜庣幇鍦═LS涓绘祦鐗堟湰鏄?.2锛屾墍浠ユ帴涓嬫潵姊崇悊鐨勬槸銆孴LS/1.2鎻℃墜杩囩▼銆?/strong>銆?/p>
闈炲绉板姞瀵嗕腑锛屾垜浠渶瑕佹槑纭殑鐐规槸馃憞 鏈変竴瀵圭閽ワ紝銆屽叕閽ャ€?/strong>鍜?span class="mq-873">銆岀閽ャ€?/strong>銆?/span> 鍏挜鍔犲瘑鐨勫唴瀹癸紝鍙湁绉侀挜鍙互瑙e紑锛岀閽ュ姞瀵嗙殑鍐呭锛屾墍鏈夌殑鍏挜閮藉彲浠ヨВ寮€锛岃繖閲岃鐨?/span>銆屽叕閽ラ兘鍙互瑙e紑锛屾寚鐨勬槸涓€瀵圭閽ャ€?/strong>銆?/span> 鍏挜鍙互鍙戦€佺粰鎵€鏈夌殑瀹㈡埛绔紝绉侀挜鍙繚瀛樺湪鏈嶅姟鍣ㄧ銆?/span> 姊崇悊璧锋潵锛屽彲浠ユ妸銆孴LS 1.2 鎻℃墜杩囩▼銆?/strong>鍒嗕负涓昏鐨勪簲姝ヰ煈?/p>
Client鍙戣捣涓€涓狧TTPS璇锋眰锛岃繛鎺?43绔彛銆傝繖涓繃绋嬪彲浠ョ悊瑙f垚鏄?span class="mq-888">銆岃姹傚叕閽ョ殑杩囩▼銆?/strong>銆?/p>
Server绔敹鍒拌姹傚悗锛岄€氳繃绗笁鏂规満鏋勭閽ュ姞瀵嗭紝浼氭妸鏁板瓧璇佷功锛堜篃鍙互璁や负鏄叕閽ヨ瘉涔︼級鍙戦€佺粰Client銆?/p>
娴忚鍣ㄥ畨瑁呭悗浼氳嚜鍔ㄥ甫涓€浜涙潈濞佺涓夋柟鏈烘瀯鍏挜锛屼娇鐢ㄥ尮閰嶇殑鍏挜瀵规暟瀛楃鍚嶈繘琛岃В瀵嗐€?/span> 鏍规嵁绛惧悕鐢熸垚鐨勮鍒欏缃戠珯淇℃伅杩涜鏈湴绛惧悕鐢熸垚锛岀劧鍚庝袱鑰呮瘮瀵广€?br> 閫氳繃姣斿涓よ€呯鍚嶏紝鍖归厤鍒欒鏄庤璇侀€氳繃锛屼笉鍖归厤鍒欒幏鍙栬瘉涔﹀け璐ャ€?/span> 鍦ㄥ畨鍏ㄦ嬁鍒?span class="mq-901">銆屾湇鍔″櫒鍏挜銆?/strong>鍚庯紝瀹㈡埛绔疌lient闅忔満鐢熸垚涓€涓?span class="mq-902">銆屽绉板瘑閽ャ€?/strong>锛屼娇鐢?span class="mq-903">銆屾湇鍔″櫒鍏挜銆?/strong>锛堣瘉涔︾殑鍏挜锛夊姞瀵嗚繖涓?span class="mq-904">銆屽绉板瘑閽ャ€?/strong>锛屽彂閫佺粰Server(鏈嶅姟鍣?銆?/p>
Server(鏈嶅姟鍣?閫氳繃鑷繁鐨勭閽ワ紝瀵逛俊鎭В瀵嗭紝鑷虫寰楀埌浜?span class="mq-907">銆屽绉板瘑閽ャ€?/strong>锛屾鏃朵袱鑰呴兘鎷ユ湁浜嗙浉鍚岀殑銆屽绉板瘑閽ャ€?/strong>銆?/p>
鎺ヤ笅鏉ワ紝灏卞彲浠ラ€氳繃璇ュ绉板瘑閽ュ浼犺緭鐨勪俊鎭姞瀵?瑙e瘑鍟︼紝浠庝笂闈㈠浘涓句釜渚嬪瓙馃憞 Client鐢ㄦ埛浣跨敤璇?span class="mq-913">銆屽绉板瘑閽ャ€?/strong>鍔犲瘑'鏄庢枃鍐呭B',鍙戦€佺粰Server(鏈嶅姟鍣? Server浣跨敤璇?/span>銆屽绉板瘑閽ャ€?/strong>杩涜瑙e瘑娑堟伅锛屽緱鍒版槑鏂囧唴瀹笲銆?/span> 鎺ヤ笅鏉ヨ€冭檻涓€涓棶棰橈紝銆屽鏋滃叕閽ヨ涓棿浜烘嬁鍒扮簜鏀规€庝箞鍔炲憿锛熴€?/strong> 銆屽鎴风鍙兘鎷垮埌鐨勫叕閽ユ槸鍋囩殑锛岃В鍐冲姙娉曟槸浠€涔堝憿锛熴€?/strong> 瀹㈡埛绔棤娉曡瘑鍒紶鍥炲叕閽ユ槸涓棿浜虹殑锛岃繕鏄湇鍔″櫒鐨勶紝杩欐槸闂鐨勬牴鏈紝鎴戜滑鏄笉鏄彲浠ラ€氳繃鏌愮瑙勮寖鍙互璁╁鎴风鍜屾湇鍔″櫒閮介伒寰煇绉嶇害瀹氬憿锛熼偅灏辨槸閫氳繃銆岀涓夋柟璁よ瘉鐨勬柟寮忋€?/strong> 鍦℉TTPS涓紝閫氳繃 銆岃瘉涔︺€?/strong> + 銆屾暟瀛楃鍚嶃€?/strong>鏉ヨВ鍐宠繖涓棶棰樸€?/p>
杩欓噷鍞竴涓嶅悓鐨勬槸锛屽亣璁惧缃戠珯淇℃伅鍔犲瘑鐨勭畻娉曟槸MD5锛岄€氳繃MD5鍔犲瘑鍚庯紝銆岀劧鍚庨€氳繃绗笁鏂规満鏋勭殑绉侀挜鍐嶆瀵瑰叾鍔犲瘑锛岀敓鎴愭暟瀛楃鍚嶃€?/strong>銆?/p>
杩欐牱瀛愮殑璇濓紝鏁板瓧璇佷功鍖呭惈鏈変袱涓壒鍒噸瑕佺殑淇℃伅馃憠銆屾煇缃戠珯鍏挜+鏁板瓧绛惧悕銆?/strong> 鎴戜滑鍐嶆鍋囪涓棿浜烘埅鍙栧埌鏈嶅姟鍣ㄧ殑鍏挜鍚庯紝鍘绘浛鎹㈡垚鑷繁鐨勫叕閽ワ紝鍥犱负鏈夋暟瀛楃鍚嶇殑瀛樺湪锛岃繖鏍峰瓙瀹㈡埛绔獙璇佸彂鐜版暟瀛楃鍚嶄笉鍖归厤锛岃繖鏍峰瓙灏遍槻姝腑闂翠汉鏇挎崲鍏挜鐨勯棶棰樸€?/p>
閭d箞瀹㈡埛绔槸濡備綍鍘诲姣斾袱鑰呮暟瀛楃鍚嶇殑鍛紵 娴忚鍣ㄤ細鍘诲畨瑁呬竴浜涙瘮杈冩潈濞佺殑绗笁鏂硅璇佹満鏋勭殑鍏挜锛屾瘮濡俈eriSign銆丼ymantec浠ュ強GlobalSign绛夌瓑銆?/span> 楠岃瘉鏁板瓧绛惧悕鐨勬椂鍊欙紝浼氱洿鎺ヤ粠鏈湴鎷垮埌鐩稿簲鐨勭涓夋柟鐨勫叕閽ワ紝瀵圭閽ュ姞瀵嗗悗鐨勬暟瀛楃鍚嶈繘琛岃В瀵嗗緱鍒扮湡姝g殑绛惧悕銆?/span> 鐒跺悗瀹㈡埛绔埄鐢ㄧ鍚嶇敓鎴愯鍒欒繘琛岀鍚嶇敓鎴愶紝鐪嬩袱涓鍚嶆槸鍚﹀尮閰嶏紝濡傛灉鍖归厤璁よ瘉閫氳繃锛屼笉鍖归厤鍒欒幏鍙栬瘉涔﹀け璐ャ€?/span> 鏁板瓧绛惧悕锛氬皢缃戠珯鐨勪俊鎭紝閫氳繃鐗瑰畾鐨勭畻娉曞姞瀵嗭紝姣斿MD5,鍔犲瘑涔嬪悗锛屽啀閫氳繃鏈嶅姟鍣ㄧ殑绉侀挜杩涜鍔犲瘑锛屽舰鎴?span class="mq-946">銆屽姞瀵嗗悗鐨勬暟瀛楃鍚嶃€?/strong>銆?/p>
绗笁鏂硅璇佹満鏋勬槸涓€涓叕寮€鐨勫钩鍙帮紝涓棿浜哄彲浠ュ幓鑾峰彇銆?/p>
鍥犱负娌℃湁璁よ瘉锛屾墍浠ヤ腑闂翠汉涔熷悜绗笁鏂硅璇佹満鏋勮繘琛岀敵璇凤紝鐒跺悗鎷︽埅鍚庢妸鎵€鏈夌殑淇℃伅閮芥浛鎹㈡垚鑷繁鐨勶紝瀹㈡埛绔粛鐒跺彲浠ヨВ瀵嗭紝骞朵笖鏃犳硶鍒ゆ柇杩欐槸鏈嶅姟鍣ㄧ殑杩樻槸涓棿浜虹殑锛屾渶鍚庨€犳垚鏁版嵁娉勯湶銆?/p>
HTTPS灏辨槸浣跨敤SSL/TLS鍗忚杩涜鍔犲瘑浼犺緭 澶ц嚧娴佺▼锛氬鎴风鎷垮埌鏈嶅姟鍣ㄧ殑鍏挜锛堟槸姝g‘鐨勶級锛岀劧鍚庡鎴风闅忔満鐢熸垚涓€涓?span class="mq-956">銆屽绉板姞瀵嗙殑绉橀挜銆?/strong>锛屼娇鐢?span class="mq-957">銆岃鍏挜銆?/strong>鍔犲瘑锛屼紶杈撶粰鏈嶅姟绔紝鏈嶅姟绔啀閫氳繃瑙e瘑鎷垮埌璇?span class="mq-958">銆屽绉扮閽ャ€?/strong>锛屽悗缁殑鎵€鏈変俊鎭兘閫氳繃璇?span class="mq-959">銆屽绉扮閽ャ€?/strong>杩涜鍔犲瘑瑙e瘑锛屽畬鎴愭暣涓狧TTPS鐨勬祦绋嬨€?/p> 銆岀涓夋柟璁よ瘉銆?/strong>锛屾渶閲嶈鐨勬槸銆屾暟瀛楃鍚嶃€?/strong>锛岄伩鍏嶄簡鑾峰彇鐨勫叕閽ユ槸涓棿浜虹殑銆?/p> 涓€鍏辨湁涓ょ鏂规硶鏉ユ仮澶嶆柇寮€鐨?SSL 杩炴帴锛屼竴绉嶆槸浣跨敤 session ID锛屼竴绉嶆槸 session ticket銆?/p>
浣跨敤 session ID 鐨勬柟寮忥紝姣忎竴娆$殑浼氳瘽閮芥湁涓€涓紪鍙凤紝褰撳璇濅腑鏂悗锛屼笅涓€娆¢噸鏂拌繛鎺ユ椂锛屽彧瑕佸鎴风缁欏嚭杩欎釜缂栧彿锛屾湇鍔″櫒濡傛灉鏈夎繖涓紪鍙风殑璁板綍锛岄偅涔堝弻鏂瑰氨鍙互缁х画浣跨敤浠ュ墠鐨勭閽ワ紝鑰屼笉鐢ㄩ噸鏂扮敓鎴愪竴鎶娿€傜洰鍓嶆墍鏈夌殑娴忚鍣ㄩ兘鏀寔杩欎竴绉嶆柟娉曘€備絾鏄繖绉嶆柟娉曟湁涓€涓己鐐规槸锛宻ession ID 鍙兘澶熷瓨鍦ㄤ竴鍙版湇鍔″櫒涓婏紝濡傛灉鎴戜滑鐨勮姹傞€氳繃璐熻浇骞宠 琚浆绉诲埌浜嗗叾浠栫殑鏈嶅姟鍣ㄤ笂锛岄偅涔堝氨鏃犳硶鎭㈠瀵硅瘽銆?/p>
鍙︿竴绉嶆柟寮忔槸 session ticket 鐨勬柟寮忥紝session ticket 鏄湇鍔″櫒鍦ㄤ笂涓€娆″璇濅腑鍙戦€佺粰瀹㈡埛鐨勶紝杩欎釜 ticket 鏄姞瀵嗙殑锛屽彧鏈夋湇鍔″櫒鑳藉瑙e瘑锛岄噷闈㈠寘鍚簡鏈浼氳瘽鐨勪俊鎭紝姣斿瀵硅瘽绉橀挜鍜屽姞瀵嗘柟娉曠瓑銆傝繖鏍蜂笉绠℃垜浠殑璇锋眰鏄惁杞Щ鍒板叾浠栫殑鏈嶅姟鍣ㄤ笂锛屽綋鏈嶅姟鍣ㄥ皢 ticket 瑙e瘑浠ュ悗锛屽氨鑳藉鑾峰彇涓婃瀵硅瘽鐨勪俊鎭紝灏变笉鐢ㄩ噸鏂扮敓鎴愬璇濈閽ヤ簡銆?/p>
鐭疆璇㈢殑鍩烘湰鎬濊矾: 娴忚鍣ㄦ瘡闅斾竴娈垫椂闂村悜娴忚鍣ㄥ彂閫?http 璇锋眰锛屾湇鍔″櫒绔湪鏀跺埌璇锋眰鍚庯紝涓嶈鏄惁鏈夋暟鎹洿鏂帮紝閮界洿鎺ヨ繘琛?鍝嶅簲銆?/span> 杩欑鏂瑰紡瀹炵幇鐨勫嵆鏃堕€氫俊锛屾湰璐ㄤ笂杩樻槸娴忚鍣ㄥ彂閫佽姹傦紝鏈嶅姟鍣ㄦ帴鍙楄姹傜殑涓€涓繃绋嬶紝閫氳繃璁╁鎴风涓嶆柇鐨勮繘琛岃姹傦紝浣垮緱瀹㈡埛绔兘澶熸ā鎷熷疄鏃跺湴鏀跺埌鏈嶅姟鍣ㄧ鐨勬暟鎹殑鍙樺寲銆?/span> 浼樼己鐐桂煈?/p>
浼樼偣鏄瘮杈冪畝鍗曪紝鏄撲簬鐞嗚В銆?/span> 缂虹偣鏄繖绉嶆柟寮忕敱浜庨渶瑕佷笉鏂殑寤虹珛 http 杩炴帴锛屼弗閲嶆氮璐逛簡鏈嶅姟鍣ㄧ鍜屽鎴风鐨勮祫婧愩€傚綋鐢ㄦ埛澧炲姞鏃讹紝鏈嶅姟鍣ㄧ鐨勫帇鍔涘氨浼氬彉澶э紝杩欐槸寰堜笉鍚堢悊鐨勩€?/span> 闀胯疆璇㈢殑鍩烘湰鎬濊矾: 棣栧厛鐢卞鎴风鍚戞湇鍔″櫒鍙戣捣璇锋眰锛屽綋鏈嶅姟鍣ㄦ敹鍒板鎴风鍙戞潵鐨勮姹傚悗锛屾湇鍔″櫒绔笉浼氱洿鎺ヨ繘琛屽搷搴旓紝鑰屾槸鍏堝皢 杩欎釜璇锋眰鎸傝捣锛岀劧鍚庡垽鏂湇鍔″櫒绔暟鎹槸鍚︽湁鏇存柊銆?/span> 濡傛灉鏈夋洿鏂帮紝鍒欒繘琛屽搷搴旓紝濡傛灉涓€鐩存病鏈夋暟鎹紝鍒欏埌杈句竴瀹氱殑鏃堕棿闄愬埗鎵嶈繑鍥炪€傚鎴风 JavaScript 鍝嶅簲澶勭悊鍑芥暟浼氬湪澶勭悊瀹屾湇鍔″櫒杩斿洖鐨勪俊鎭悗锛屽啀娆″彂鍑鸿姹傦紝閲嶆柊寤虹珛杩炴帴銆?/span> 浼樼己鐐桂煈?/p>
闀胯疆璇㈠拰鐭疆璇㈡瘮璧锋潵锛屽畠鐨勪紭鐐规槸銆屾槑鏄惧噺灏戜簡寰堝涓嶅繀瑕佺殑 http 璇锋眰娆℃暟銆?/strong>锛岀浉姣斾箣涓嬭妭绾︿簡璧勬簮銆?/span> 闀胯疆璇㈢殑缂虹偣鍦ㄤ簬锛岃繛鎺ユ寕璧蜂篃浼氬鑷磋祫婧愮殑娴垂銆?/span> WebSocket 鏄?Html5 瀹氫箟鐨勪竴涓柊鍗忚锛屼笌浼犵粺鐨?http 鍗忚涓嶅悓锛岃鍗忚鍏佽鐢辨湇鍔″櫒涓诲姩鐨勫悜瀹㈡埛绔帹閫佷俊鎭€?/span> 浣跨敤 WebSocket 鍗忚鐨勭己鐐规槸鍦ㄦ湇鍔″櫒绔殑閰嶇疆姣旇緝澶嶆潅銆俉ebSocket 鏄竴涓叏鍙屽伐鐨勫崗璁紝涔熷氨鏄€氫俊鍙屾柟鏄钩绛夌殑锛屽彲浠ョ浉浜掑彂閫佹秷鎭€?br> 鎴戜滑甯歌鐨勪唬鐞嗕篃灏辨槸鎸囨鍚戜唬鐞嗭紝姝e悜浠g悊鐨勮繃绋嬶紝瀹冮殣钘忎簡鐪熷疄鐨勮姹傚鎴风锛屾湇鍔$涓嶇煡閬撶湡瀹炵殑瀹㈡埛绔槸璋侊紝瀹㈡埛绔姹傜殑鏈嶅姟閮借浠g悊鏈嶅姟鍣ㄤ唬鏇挎潵璇锋眰銆?/p>
杩欑浠g悊妯″紡涓嬶紝瀹冮殣钘忎簡鐪熷疄鐨勬湇鍔$锛屽綋鎴戜滑鍚戜竴涓綉绔欏彂璧疯姹傜殑鏃跺€欙紝鑳屽悗鍙兘鏈夋垚鍗冧笂涓囧彴鏈嶅姟鍣ㄤ负鎴戜滑鏈嶅姟锛屽叿浣撴槸鍝竴鍙帮紝鎴戜滑涓嶆竻妤氾紝鎴戜滑鍙渶瑕佺煡閬撳弽鍚戜唬鐞嗘湇鍔″櫒鏄皝灏辫锛岃€屼笖鍙嶅悜浠g悊鏈嶅姟鍣ㄤ細甯垜浠妸璇锋眰杞彂鍒扮湡瀹炵殑鏈嶅姟鍣ㄩ偅閲屽幓锛屼竴鑸€岃█鍙嶅悜浠g悊鏈嶅姟鍣ㄤ竴鑸敤鏉ュ疄鐜拌礋杞藉钩琛°€?/p>
涓€绉嶆槸浣跨敤鍙嶅悜浠g悊鐨勬柟寮忥紝鐢ㄦ埛鐨勮姹傞兘鍙戦€佸埌鍙嶅悜浠g悊鏈嶅姟涓婏紝鐒跺悗鐢卞弽鍚戜唬鐞嗘湇鍔″櫒鏉ヨ浆鍙戣姹傚埌鐪熷疄鐨勬湇鍔″櫒涓婏紝浠ユ鏉ュ疄鐜伴泦缇ょ殑璐熻浇骞宠 銆?/span> 鍚銆?9% 鐨勪汉閮界悊瑙i敊浜?HTTP 涓?GET 涓?POST 鐨勫尯鍒€忥紵锛?/span> 濡備綍鐞嗚ВHTTP鍝嶅簲鐨勭姸鎬佺爜 HTTP 鍝嶅簲浠g爜 | MDN 鍥捐В HTTP 缂撳瓨 鐪嬪畬杩欑瘒HTTP锛岃窡闈㈣瘯瀹樻壇鐨氨娌¢棶棰樹簡 HTTP keep-alive 浜屼笁浜?/span> 娣卞叆鐞嗚ВHTTPS宸ヤ綔鍘熺悊 鐪嬪浘瀛TTPS 杞銆侀暱杞銆侀暱杩炴帴銆亀ebsocket DNS 鍘熺悊鍏ラ棬 以上是关于銆屾煡缂鸿ˉ婕忋€嶅珐鍥轰綘鐨凥TTP鐭ヨ瘑浣撶郴的主要内容,如果未能解决你的问题,请参考以下文章 涓€绔欐敹褰曡绠楁満鐭ヨ瘑浣撶郴锛氱畻娉曘€佹搷浣滅郴缁熴€佹暟鎹簱銆佺紪绋嬪疄璺点€佺郴缁熻璁$瓑闈炲绉板姞瀵?/h3>
涓昏宸ヤ綔娴佺▼
姝ラ(1)
姝ラ(2)
姝ラ(3)
姝ラ(4)
姝ラ(5)
绗笁鏂硅璇?/h3>
鏁板瓧绛惧悕浣滅敤
銆屾€荤粨銆?/strong>
SSL 杩炴帴鏂紑鍚庡浣曟仮澶嶏紵
閫氳繃session ID
閫氳繃session ticket
鐭疆璇€侀暱杞鍜?WebSocket 闂寸殑鍖哄埆锛?/h2>
鐭疆璇?/h3>
闀胯疆璇?/h3>
WebSocket
璇翠竴璇存鍚戜唬鐞嗗拰鍙嶅悜浠g悊
姝e悜浠g悊
鍙嶅悜浠g悊
璐熻浇骞宠 鐨勪袱绉嶅疄鐜版柟寮忥紵
鍙傝€?/h2>
鍏充簬濂囪垶鍛ㄥ垔