非加密http2.0

來源:互聯網
上載者:User

標籤:http2.0 okhttp nginx

用戶端 okhttp/3.4.1

http2.0協議本身並不要求基於https,但是瀏覽器,伺服器都要求http2.0 over https,畢竟https是大勢所趨嘛。想體驗2.0的低延遲,先把https做好。

因此,使用非加密的http2.0需要對okhttp源碼進行修改,修改起來並不複雜,我的策略是在協議為http時,判斷host,如果是我們的網域名稱xxx.suning.com,協議返回HTTP_2。

650) this.width=650;" class="confluence-embedded-image" title="效能最佳化及問題診斷 > 2017/07/26 > 非加密http2.0 > image2017-8-2 20:36:19.png" src="http://wiki.cnsuning.com/download/attachments/28011359/image2017-8-2%2020%3A36%3A19.png?version=1&modificationDate=1501677379301&api=v2" style="color:rgb(51,51,51);font-family:Arial, sans-serif;font-size:14px;white-space:normal;background-color:rgb(255,255,255);" alt="image2017-8-2%2020%3A36%3A19.png?version" />

服務端 nginx/1.10

以前總是認為,http2.0必須且只能配置在server的443連接埠,配置在80連接埠,肯定報錯。經過實踐,應該是這樣的,http2.0不能配置在80連接埠,其他所有連接埠都可以,比如81、82、83、443。。。。

測試時,在81連接埠配置了http2.0。用戶端訪問http://xxx.suning.com:81,協議為h2。

650) this.width=650;" class="confluence-embedded-image" src="http://wiki.cnsuning.com/download/attachments/28011359/image2017-7-26%2011%3A0%3A53.png?version=1&modificationDate=1501038053000&api=v2&effects=border-simple,blur-border" style="margin:0px;padding:0px;border:0px;" alt="image2017-7-26%2011%3A0%3A53.png?version" />

作用

對於單條介面來說,如果去掉SSL握手過程,可以減少大概180ms。

現在依然沒有強制執行https,非加密的http2.0仍有用武之地。

本文出自 “13173662” 部落格,請務必保留此出處http://13183662.blog.51cto.com/13173662/1953093

非加密http2.0

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.